Skip to content

Commit

Permalink
feat: cache assets using cache-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocodutra authored and jantimon committed Aug 14, 2019
1 parent 0af4230 commit f2758ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"webpack-merge": "4.1.2"
},
"dependencies": {
"cache-loader": "^1.2.2",
"camelcase": "^4.1.0",
"favicons": "^4.8.6",
"find-root": "^1.1.0",
Expand Down
7 changes: 4 additions & 3 deletions src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ module.exports.run = ({prefix, favicons: options, logo}, context, compilation) =
const compiler = compilation.createChildCompiler('favicons-webpack-plugin', {filename, publicPath});
compiler.context = context;

const loader = require.resolve('./loader');
const query = JSON.stringify({prefix, options});
const cacheDirectory = path.resolve(context, '.wwp-cache');
const cache = `${require.resolve('cache-loader')}?${JSON.stringify({cacheDirectory})}`;
const loader = `${require.resolve('./loader')}?${JSON.stringify({prefix, options})}`;

new SingleEntryPlugin(context, `!!${loader}?${query}!${logo}`).apply(compiler);
new SingleEntryPlugin(context, `!!${cache}!${loader}!${logo}`).apply(compiler);

// Compile and return a promise
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit f2758ca

Please sign in to comment.