2019-12-07 16:58:52 +05:30
|
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
2016-11-27 17:27:11 +05:30
|
|
|
/* 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') {
|
2019-11-27 14:33:32 +05:30
|
|
|
throw new Error('Dll plugin should be used for dev mode only');
|
2019-07-01 09:09:59 +05:30
|
|
|
}
|
|
|
|
|
2016-11-27 17:27:11 +05:30
|
|
|
const outputPath = path.join(__dirname, 'dll');
|
|
|
|
|
|
|
|
const webpackConfig = {
|
2019-11-27 14:33:32 +05:30
|
|
|
mode: 'development',
|
|
|
|
|
|
|
|
entry: {
|
2019-12-30 13:12:02 +05:30
|
|
|
vendor: vendor.filter(
|
2020-05-20 22:05:52 +05:30
|
|
|
(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'),
|
|
|
|
),
|
2019-11-27 14:33:32 +05:30
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
filename: '[name].dll.js?[hash]',
|
|
|
|
path: outputPath,
|
|
|
|
library: '[name]',
|
|
|
|
publicPath: '/',
|
|
|
|
},
|
|
|
|
|
2020-01-18 02:07:52 +05:30
|
|
|
// @ts-ignore
|
2019-12-30 13:12:02 +05:30
|
|
|
resolve: baseConfig.resolve,
|
2019-12-08 01:31:48 +05:30
|
|
|
|
2019-11-27 14:33:32 +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,
|
|
|
|
}),
|
2019-11-27 14:33:32 +05:30
|
|
|
],
|
2016-11-27 17:27:11 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = webpackConfig;
|