Skip to content

Commit

Permalink
Simplify razzle config
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed May 7, 2021
1 parent 457bdfe commit 0ad1f75
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions razzle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,4 @@ Object.keys(pathsConfig).forEach((pkg) => {
}
});

if (process.env.NODE_ENV === 'production') {
module.exports = require(`${voltoPath}/razzle.config`);
} else {
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

let voltoConfig = require(`${voltoPath}/razzle.config`);

module.exports = {
...voltoConfig,
modifyWebpackConfig: (opts) => {
const vc = voltoConfig.modifyWebpackConfig(opts);
const hardSource = new HardSourceWebpackPlugin({
// Either an absolute path or relative to webpack's options.context.
cacheDirectory: 'node_modules/.cache/hard-source/[confighash]',
// Either a string of object hash function given a webpack config.
configHash: function (webpackConfig) {
// node-object-hash on npm can be used to build this.
return require('node-object-hash')({ sort: false }).hash(
webpackConfig,
);
},
// Either false, a string, an object, or a project hashing function.
environmentHash: {
root: process.cwd(),
directories: [],
files: ['package-lock.json', 'yarn.lock'],
},
// An object.
info: {
// 'none' or 'test'.
mode: 'none',
// 'debug', 'log', 'info', 'warn', or 'error'.
level: 'debug',
},
// Clean up large, old caches automatically.
cachePrune: {
// Caches younger than `maxAge` are not considered for deletion. They must
// be at least this (default: 2 days) old in milliseconds.
maxAge: 2 * 24 * 60 * 60 * 1000,
// All caches together must be larger than `sizeThreshold` before any
// caches will be deleted. Together they must be at least this
// (default: 50 MB) big in bytes.
sizeThreshold: 50 * 1024 * 1024,
},
});
vc.plugins.push(hardSource);
return vc;
},
};
}
module.exports = require(`${voltoPath}/razzle.config`);

0 comments on commit 0ad1f75

Please sign in to comment.