1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-03-24 20:49:47 +01:00
php-web-maker/preact.config.js

58 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2019-07-15 21:50:41 +05:30
// var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
2018-06-16 14:56:14 +05:30
/**
* Function that mutates original webpack config.
* Supports asynchronous changes when promise is returned.
*
* @param {object} config - original webpack config.
* @param {object} env - options passed to CLI.
* @param {WebpackConfigHelpers} helpers - object with useful helpers when working with config.
**/
2021-01-18 16:32:06 +05:30
export default function (config, env, helpers) {
2018-06-22 14:45:15 +05:30
const htmlWebpackPlugin = helpers.getPluginsByName(
config,
'HtmlWebpackPlugin'
)[0];
Object.assign(htmlWebpackPlugin.plugin.options.minify, {
removeComments: false,
2021-04-01 14:45:32 +05:30
collapseWhitespace: false
2018-06-22 14:45:15 +05:30
});
htmlWebpackPlugin.plugin.options.preload = false;
htmlWebpackPlugin.plugin.options.favicon = false;
2018-11-03 12:42:21 +05:30
// Required for lingui-macros
let { rule } = helpers.getLoadersByName(config, 'babel-loader')[0];
let babelConfig = rule.options;
babelConfig.plugins.push('macros');
2018-06-16 14:56:14 +05:30
if (env.isProd) {
config.devtool = false; // disable sourcemaps
// To support chunk loading in root and also /app path
config.output.publicPath = './';
// Remove the default hash append in chunk name
config.output.chunkFilename = '[name].chunk.js';
2019-07-15 21:50:41 +05:30
// config.plugins.push(
// new CommonsChunkPlugin({
// name: 'vendor',
// minChunks: ({ resource }) => /node_modules/.test(resource)
// })
// );
2018-06-16 14:56:14 +05:30
2018-06-22 14:45:15 +05:30
const swPlugin = helpers.getPluginsByName(
config,
'SWPrecacheWebpackPlugin'
)[0];
2021-01-18 16:32:06 +05:30
if (swPlugin) {
2021-04-01 14:45:32 +05:30
// config.plugins.splice(swPlugin.index, 1);
2021-01-18 16:32:06 +05:30
}
2018-06-16 14:56:14 +05:30
2018-06-22 14:45:15 +05:30
const uglifyPlugin = helpers.getPluginsByName(config, 'UglifyJsPlugin')[0];
2021-01-18 16:32:06 +05:30
if (uglifyPlugin) {
2021-04-01 14:45:32 +05:30
// config.plugins.splice(uglifyPlugin.index, 1);
2021-01-18 16:32:06 +05:30
}
2018-06-16 14:56:14 +05:30
}
}