accounts-frontend/webpack.dll.config.js

50 lines
1.1 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-07 16:58:52 +05:30
const isProduction = process.argv.some(arg => arg === '-p');
const isTest = process.argv.some(arg => arg.indexOf('karma') !== -1);
process.env.NODE_ENV = 'development';
2019-07-01 09:09:59 +05:30
if (isTest) {
process.env.NODE_ENV = 'test';
}
2019-07-01 09:09:59 +05:30
if (isProduction) {
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-08 01:31:48 +05:30
vendor,
},
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'],
},
plugins: [
new webpack.DllPlugin({
name: '[name]',
path: path.join(outputPath, '[name].json'),
}),
],
};
module.exports = webpackConfig;