const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const ROOT_PATH = path.resolve(__dirname);
const APP_PATH = path.resolve(ROOT_PATH, 'src');
const BUILD_PATH = path.resolve(ROOT_PATH, 'dist');
const NODE_MODULES_PATH = path.resolve(ROOT_PATH, 'node_modules');
const ENTRY_FILE = path.resolve(APP_PATH, 'index');
const TEMPLATE_FILE = path.resolve(APP_PATH, 'index.html'); //html
module.exports = [
{
mode: 'development',
devtool: 'source-map',
entry: {
app: ENTRY_FILE,
vendor: [
"angular",
'@uirouter/angularjs'
]
},
output: {
path: BUILD_PATH,
filename: 'js/[name].[hash:8].js',
chunkFilename: '[name].[chunkhash:8].js',
publicPath: '/'
},
devServer: {
hot: true,
contentBase: BUILD_PATH,
port: 3000,
publicPath: '/'
},
plugins: [
new HtmlWebpackPlugin({
filename: path.resolve(BUILD_PATH, 'index.html'),
template: TEMPLATE_FILE,
hash: false,
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
],
optimization: {
splitChunks: {
cacheGroups: {
common: {
chunks: 'all',
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
name: 'common'
},
vendor: {
test: /node_modules/,
chunks: 'all',
name: 'vendor',
priority: 10,
enforce: true,
minChunks: 2
}
}
}
},
resolve: {
extensions: ['.js', '.ts', '.less', '.scss', '.css'],
alias: {
'@': APP_PATH,
}
}
},
{
mode: 'development',
entry: path.resolve(__dirname, 'lib/FrontblockLib.js'),
output: {
path: path.resolve(__dirname, 'static'),
filename: 'FrontblockLib.js',
},
module: {
rules: [
{ test: /\FrontblockLib.ts/, use: 'ts-loader' }
]
},
optimization: {
minimizer: [new TerserPlugin({
cache: true,
parallel: true,
terserOptions:{
mangle: false,
keep_classnames: true
}
})],
splitChunks: {
cacheGroups: {
common: {
chunks: 'all',
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
name: 'common'
},
vendor: {
test: /node_modules/,
chunks: 'all',
name: 'vendor',
priority: 10,
enforce: true,
minChunks: 2
}
}
}
}
}
];