|
|
@ -1,21 +1,31 @@ |
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
|
|
|
const webpack = require("webpack"); |
|
|
|
const path = require('path'); |
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
|
|
|
|
|
|
|
const TerserPlugin = require("terser-webpack-plugin"); |
|
|
|
|
|
|
|
const path = require("path"); |
|
|
|
|
|
|
|
const autoprefixer = require("autoprefixer"); |
|
|
|
|
|
|
|
const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); |
|
|
|
|
|
|
|
const CircularDependencyPlugin = require("circular-dependency-plugin"); |
|
|
|
|
|
|
|
const childProcess = require("child_process"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function git(command) { |
|
|
|
|
|
|
|
return childProcess.execSync(`git ${command}`).toString().trim(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
module.exports = { |
|
|
|
mode: 'production', |
|
|
|
mode: "production", |
|
|
|
entry: './src/index.js', |
|
|
|
entry: "./src/bundle.js", |
|
|
|
devServer: { |
|
|
|
output: { |
|
|
|
port: 3000, |
|
|
|
path: path.resolve(__dirname, "dist"), |
|
|
|
liveReload: true, |
|
|
|
filename: "[name].js", |
|
|
|
}, |
|
|
|
}, |
|
|
|
devtool: 'hidden-source-map', |
|
|
|
devtool: false, |
|
|
|
module: { |
|
|
|
module: { |
|
|
|
rules: [ |
|
|
|
rules: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
test: /\.js$/, |
|
|
|
test: /\.js$/, |
|
|
|
exclude: /node_modules/, |
|
|
|
exclude: /node_modules/, |
|
|
|
use: { |
|
|
|
use: { |
|
|
|
loader: 'babel-loader', |
|
|
|
loader: "babel-loader", |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
@ -23,22 +33,22 @@ module.exports = { |
|
|
|
use: [ |
|
|
|
use: [ |
|
|
|
MiniCssExtractPlugin.loader, |
|
|
|
MiniCssExtractPlugin.loader, |
|
|
|
{ |
|
|
|
{ |
|
|
|
loader: 'css-loader', |
|
|
|
loader: "css-loader", |
|
|
|
options: { |
|
|
|
options: { |
|
|
|
url: false, |
|
|
|
url: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
loader: 'postcss-loader', |
|
|
|
loader: "postcss-loader", |
|
|
|
options: { |
|
|
|
options: { |
|
|
|
plugins: [autoprefixer], |
|
|
|
plugins: [autoprefixer], |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
loader: 'less-loader', |
|
|
|
loader: "less-loader", |
|
|
|
options: { |
|
|
|
options: { |
|
|
|
relativeUrls: false, |
|
|
|
relativeUrls: false, |
|
|
|
modifyVars: lessVariables, |
|
|
|
// modifyVars: lessVariables,
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
@ -46,32 +56,26 @@ module.exports = { |
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
resolve: { |
|
|
|
resolve: { |
|
|
|
extensions: ['.js', '.ts'], |
|
|
|
extensions: [".js", ".ts"], |
|
|
|
alias: { |
|
|
|
alias: { |
|
|
|
'@': path.resolve(__dirname, '../src'), |
|
|
|
"@": path.resolve(__dirname, "src"), |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
plugins: [ |
|
|
|
plugins: [ |
|
|
|
new MiniCssExtractPlugin({ |
|
|
|
new CircularDependencyPlugin(), |
|
|
|
path: dirs.DEST, |
|
|
|
|
|
|
|
filename: '[name].css', |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
new ForkTsCheckerWebpackPlugin({}), |
|
|
|
|
|
|
|
new OptimizeCssAssetsPlugin({ |
|
|
|
|
|
|
|
assetNameRegExp: /\.css$/g, |
|
|
|
|
|
|
|
cssProcessor: require('cssnano'), |
|
|
|
|
|
|
|
cssProcessorPluginOptions: { |
|
|
|
|
|
|
|
preset: [ |
|
|
|
|
|
|
|
'default', |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
discardComments: { |
|
|
|
|
|
|
|
removeAll: true, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
normalizeUnicode: false, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
}, |
|
|
|
optimization: { |
|
|
|
canPrint: true, |
|
|
|
usedExports: false, |
|
|
|
|
|
|
|
minimize: true, |
|
|
|
|
|
|
|
minimizer: [ |
|
|
|
|
|
|
|
new TerserPlugin({ |
|
|
|
|
|
|
|
include: /\.js$/i, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
new webpack.BannerPlugin({ |
|
|
|
|
|
|
|
banner: `time: ${new Date().toLocaleString()}; branch: ${git( |
|
|
|
|
|
|
|
"name-rev --name-only HEAD" |
|
|
|
|
|
|
|
)} commit: ${git("rev-parse HEAD")}`,
|
|
|
|
}), |
|
|
|
}), |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|