59 lines
1.6 KiB
59 lines
1.6 KiB
2 years ago
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||
|
const path = require('path');
|
||
|
const TerserPlugin = require("terser-webpack-plugin");
|
||
|
const webpack = require("webpack");
|
||
|
const childProcess = require("child_process");
|
||
|
|
||
|
function git(command) {
|
||
|
return childProcess.execSync(`git ${command}`).toString().trim();
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
mode: 'production',
|
||
|
entry: {
|
||
|
"demo.min": './src/index.js'
|
||
|
},
|
||
|
module: {
|
||
|
rules: [
|
||
|
{
|
||
|
test: /\.js$/,
|
||
|
exclude: /node_modules/,
|
||
|
use: {
|
||
|
loader: 'babel-loader',
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
test: /\.less$/i,
|
||
|
use: ['style-loader', 'css-loader', 'less-loader'],
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
devtool: 'source-map',
|
||
|
resolve: {
|
||
|
extensions: ['.js', '.ts'],
|
||
|
alias: {
|
||
|
'@': path.resolve(__dirname, './src'),
|
||
|
},
|
||
|
},
|
||
|
optimization: {
|
||
|
usedExports: false,
|
||
|
minimize: true,
|
||
|
minimizer: [
|
||
|
new TerserPlugin({
|
||
|
include: /\.min/,
|
||
|
parallel: true,
|
||
|
terserOptions: {
|
||
|
output: {
|
||
|
comments: false,
|
||
|
},
|
||
|
},
|
||
|
}),
|
||
|
new webpack.BannerPlugin({
|
||
|
banner: `time: ${new Date().toLocaleString("en-US")}; branch: ${git(
|
||
|
"name-rev --name-only HEAD"
|
||
|
)} commit: ${git("rev-parse HEAD")}`,
|
||
|
})
|
||
|
],
|
||
|
},
|
||
|
};
|