Treecat
2 years ago
2 changed files with 60 additions and 1 deletions
@ -0,0 +1,58 @@
|
||||
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")}`,
|
||||
}) |
||||
], |
||||
}, |
||||
}; |
Loading…
Reference in new issue