accounts-frontend/webpack.dll.config.js

47 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-12-07 16:58:52 +05:30
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-env node */
const path = require('path');
const webpack = require('webpack');
2019-12-08 01:31:48 +05:30
const vendor = Object.keys(require('./packages/app/package.json').dependencies);
2019-12-30 13:12:02 +05:30
const baseConfig = require('./babel.config');
2019-12-07 16:58:52 +05:30
2019-12-30 13:12:02 +05:30
if (process.env.NODE_ENV === 'production') {
throw new Error('Dll plugin should be used for dev mode only');
2019-07-01 09:09:59 +05:30
}
const outputPath = path.join(__dirname, 'dll');
const webpackConfig = {
mode: 'development',
entry: {
2019-12-30 13:12:02 +05:30
vendor: vendor.filter(
(item) =>
2019-12-30 13:12:02 +05:30
// if we include rhl in dll. It won't work for some reason
!item.includes('react-hot-loader'),
),
},
output: {
filename: '[name].dll.js?[hash]',
path: outputPath,
library: '[name]',
publicPath: '/',
},
// @ts-ignore
2019-12-30 13:12:02 +05:30
resolve: baseConfig.resolve,
2019-12-08 01:31:48 +05:30
plugins: [
new webpack.DllPlugin({
name: '[name]',
path: path.join(outputPath, '[name].json'),
}),
2019-12-13 12:49:00 +05:30
new webpack.EnvironmentPlugin({
NODE_ENV: process.env.NODE_ENV,
}),
],
};
module.exports = webpackConfig;