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-07 16:58:52 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
const isProduction = process.argv.some(arg => arg === '-p');
|
|
|
|
const isTest = process.argv.some(arg => arg.indexOf('karma') !== -1);
|
2016-11-27 17:27:11 +05:30
|
|
|
|
|
|
|
process.env.NODE_ENV = 'development';
|
2019-07-01 09:09:59 +05:30
|
|
|
|
2016-11-27 17:27:11 +05:30
|
|
|
if (isTest) {
|
2019-11-27 14:33:32 +05:30
|
|
|
process.env.NODE_ENV = 'test';
|
2016-11-27 17:27:11 +05:30
|
|
|
}
|
|
|
|
|
2019-07-01 09:09:59 +05:30
|
|
|
if (isProduction) {
|
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-08 01:31:48 +05:30
|
|
|
vendor,
|
2019-11-27 14:33:32 +05:30
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
filename: '[name].dll.js?[hash]',
|
|
|
|
path: outputPath,
|
|
|
|
library: '[name]',
|
|
|
|
publicPath: '/',
|
|
|
|
},
|
|
|
|
|
2019-12-08 01:31:48 +05:30
|
|
|
resolve: {
|
|
|
|
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
|
|
|
modules: ['./packages/app/node_modules', './node_modules'],
|
|
|
|
},
|
|
|
|
|
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;
|