Skip to content

Commit

Permalink
Match all files in public folder for sw.js (mui#187)
Browse files Browse the repository at this point in the history
Currently, only first-level content of public folder will be included in sw.js, including folders. This way, only files, including nested ones, will be included. 

Also, don't use basename as it doesn't play nicely with deep files, instead use path.relative()
  • Loading branch information
Benjamin Kniffler authored and ctrlplusb committed Nov 28, 2016
1 parent 740f306 commit f572ab9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/webpack/configFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ function webpackConfigFactory({ target, mode }, { json }) {
const clientBundleAssets = globSync(
path.resolve(appRootPath, envVars.BUNDLE_OUTPUT_PATH, './client/*.js')
);
return globSync(path.resolve(appRootPath, './public/*'))
return globSync(path.resolve(appRootPath, './public/**/*.*'))
.reduce((acc, cur) => {
// We will precache our public asset, with it being invalidated
// any time our client bundle assets change.
acc[`/${path.basename(cur)}`] = clientBundleAssets; // eslint-disable-line no-param-reassign,max-len
acc[`/${path.relative(path.resolve(appRootPath, 'public'), cur)}`] = clientBundleAssets; // eslint-disable-line no-param-reassign,max-len
return acc;
},
{
Expand Down

0 comments on commit f572ab9

Please sign in to comment.