forked from fanruan/fineui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
58 lines
1.6 KiB
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")}`, |
|
}) |
|
], |
|
}, |
|
};
|
|
|