Skip to content

Commit

Permalink
chore: add assetlinks.json files
Browse files Browse the repository at this point in the history
- extend webpack copy config to allow renaming files on the fly
  • Loading branch information
neopostmodern committed Aug 31, 2022
1 parent f67ad7d commit a907467
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
22 changes: 18 additions & 4 deletions client/.erb/configs/webpack.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,24 @@ export const createPluginsForPWA = ({
}),
new CopyWebpackPlugin({
patterns: [...assetFileNames, ...additionalAssetFileNames].map(
(assetFileName) => ({
from: path.join(assetsFolderPath, assetFileName),
to: assetFileName.includes('/') ? assetFileName : undefined, // see https://github.com/webpack-contrib/copy-webpack-plugin/issues/137#issuecomment-464339172
})
(assetFileName) => {
let fromAssetFileName;
let toAssetFileName;
if (Array.isArray(assetFileName)) {
fromAssetFileName = assetFileName[0];
toAssetFileName = assetFileName[1];
} else {
fromAssetFileName = assetFileName;
toAssetFileName = assetFileName;
}
return {
from: path.join(assetsFolderPath, fromAssetFileName),
to:
toAssetFileName.includes('/') || !toAssetFileName.startsWith('.')
? toAssetFileName
: undefined, // see https://github.com/webpack-contrib/copy-webpack-plugin/issues/137#issuecomment-464339172
};
}
),
}),
];
Expand Down
12 changes: 11 additions & 1 deletion client/.erb/configs/webpack.config.renderer.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,17 @@ const configuration: webpack.Configuration = {

configPlugin,

...createPluginsForPWA({ additionalAssetFileNames: ['.htaccess'] }),
...createPluginsForPWA({
additionalAssetFileNames: [
'.htaccess',
[
config.CHANNEL === 'staging'
? '.well-known/assetlinks-staging.json'
: '.well-known/assetlinks-prod.json',
'.well-known/assetlinks.json',
],
],
}),
],
};

Expand Down
14 changes: 14 additions & 0 deletions client/assets/.well-known/assetlinks-prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "love.structure.app.twa",
"sha256_cert_fingerprints": [
"77:FC:D1:1C:E0:F4:01:61:D5:98:37:C6:1F:CF:15:01:79:64:A8:65:66:6C:EA:9A:E7:43:D2:92:26:E0:CD:47"
]
}
}
]
14 changes: 14 additions & 0 deletions client/assets/.well-known/assetlinks-staging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "love.structure.staging_app.twa",
"sha256_cert_fingerprints": [
"F7:E1:04:AA:10:E1:73:55:2C:EF:BA:0B:7E:14:8B:07:09:0A:66:75:01:12:CD:D1:B6:E4:56:84:91:43:FD:66"
]
}
}
]

0 comments on commit a907467

Please sign in to comment.