Browse Source

KERNEL-14512 chore: demo 支持 build

es6
Treecat 2 years ago
parent
commit
881b2e1fd4
  1. 3
      packages/demo/package.json
  2. 58
      packages/demo/webpack.prod.js

3
packages/demo/package.json

@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --open --config=webpack.dev.js"
"dev": "webpack-dev-server --open --config=webpack.dev.js",
"build": "webpack --config=webpack.prod.js"
},
"keywords": [],
"author": "",

58
packages/demo/webpack.prod.js

@ -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…
Cancel
Save