Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { getSettings } = lila;
const [root, srcDir, buildDir] = getSettings(['root', 'src', 'build']);
const srcPath = join(root, srcDir);
const buildPath = join(root, buildDir);
const {
staticServer = '',
minCss = !0,
splitChunks = defaultSplitChunks,
} = config;
const baseConfig = base(lila, webpack, { entry, cmd, config });
baseConfig.plugins.push(
new WebpackBar(),
new SpeedMeasurePlugin(),
// css standalone
new MiniCssExtractPlugin({
filename: '[chunkhash].css',
})
);
baseConfig.optimization.splitChunks = splitChunks;
if (minCss)
baseConfig.plugins.push(
new OptimizeCssAssetsPlugin({
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
},
})
);
const { BannerPlugin } = webpack;
const {
minCss = !0,
filename = '',
library = 'Index',
banner = '',
externals,
} = config;
const baseConfig = base(lila, webpack, { entry, cmd, config });
baseConfig.plugins.push(
new WebpackBar(),
new SpeedMeasurePlugin(),
// css standalone
new MiniCssExtractPlugin({
filename: `${filename || 'style'}.css`,
})
);
if (minCss)
baseConfig.plugins.push(
new OptimizeCssAssetsPlugin({
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
},
})
);
if (banner) baseConfig.plugins.push(new BannerPlugin(banner));
export function smp(buildConfig: BuildConfig, webpackConfig: webpack.Configuration) {
const smpPlugin = new SpeedMeasurePlugin()
return buildConfig.SMP ? smpPlugin.wrap(webpackConfig) : webpackConfig
}
export default (lila, webpack, { entry, cmd, config }) => {
const { getSettings } = lila;
const [root, srcDir, tmpDir, analyzeDir = 'analyze'] = getSettings([
'root',
'src',
'tmp',
'analyze',
]);
const srcPath = join(root, srcDir);
const analyzePath = join(root, tmpDir, analyzeDir);
const baseConfig = base(lila, webpack, { entry, cmd, config });
baseConfig.plugins.push(new WebpackBar(), new SpeedMeasurePlugin());
return {
entry: `${srcPath}/${entry === defaultEntry ? '' : `${entry}/`}index.js`,
output: {
path: analyzePath,
filename: 'index.js',
},
...baseConfig,
};
};