|
|
|
@ -1,21 +1,31 @@
|
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
|
|
|
|
const path = require('path'); |
|
|
|
|
const webpack = require("webpack"); |
|
|
|
|
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 = { |
|
|
|
|
mode: 'production', |
|
|
|
|
entry: './src/index.js', |
|
|
|
|
devServer: { |
|
|
|
|
port: 3000, |
|
|
|
|
liveReload: true, |
|
|
|
|
mode: "production", |
|
|
|
|
entry: "./src/bundle.js", |
|
|
|
|
output: { |
|
|
|
|
path: path.resolve(__dirname, "dist"), |
|
|
|
|
filename: "[name].js", |
|
|
|
|
}, |
|
|
|
|
devtool: 'hidden-source-map', |
|
|
|
|
devtool: false, |
|
|
|
|
module: { |
|
|
|
|
rules: [ |
|
|
|
|
{ |
|
|
|
|
test: /\.js$/, |
|
|
|
|
exclude: /node_modules/, |
|
|
|
|
use: { |
|
|
|
|
loader: 'babel-loader', |
|
|
|
|
loader: "babel-loader", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
@ -23,22 +33,22 @@ module.exports = {
|
|
|
|
|
use: [ |
|
|
|
|
MiniCssExtractPlugin.loader, |
|
|
|
|
{ |
|
|
|
|
loader: 'css-loader', |
|
|
|
|
loader: "css-loader", |
|
|
|
|
options: { |
|
|
|
|
url: false, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
loader: 'postcss-loader', |
|
|
|
|
loader: "postcss-loader", |
|
|
|
|
options: { |
|
|
|
|
plugins: [autoprefixer], |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
loader: 'less-loader', |
|
|
|
|
loader: "less-loader", |
|
|
|
|
options: { |
|
|
|
|
relativeUrls: false, |
|
|
|
|
modifyVars: lessVariables, |
|
|
|
|
// modifyVars: lessVariables,
|
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
@ -46,32 +56,26 @@ module.exports = {
|
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
resolve: { |
|
|
|
|
extensions: ['.js', '.ts'], |
|
|
|
|
extensions: [".js", ".ts"], |
|
|
|
|
alias: { |
|
|
|
|
'@': path.resolve(__dirname, '../src'), |
|
|
|
|
"@": path.resolve(__dirname, "src"), |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
plugins: [ |
|
|
|
|
new MiniCssExtractPlugin({ |
|
|
|
|
path: dirs.DEST, |
|
|
|
|
filename: '[name].css', |
|
|
|
|
}), |
|
|
|
|
new ForkTsCheckerWebpackPlugin({}), |
|
|
|
|
new OptimizeCssAssetsPlugin({ |
|
|
|
|
assetNameRegExp: /\.css$/g, |
|
|
|
|
cssProcessor: require('cssnano'), |
|
|
|
|
cssProcessorPluginOptions: { |
|
|
|
|
preset: [ |
|
|
|
|
'default', |
|
|
|
|
{ |
|
|
|
|
discardComments: { |
|
|
|
|
removeAll: true, |
|
|
|
|
}, |
|
|
|
|
normalizeUnicode: false, |
|
|
|
|
}, |
|
|
|
|
new CircularDependencyPlugin(), |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
canPrint: true, |
|
|
|
|
optimization: { |
|
|
|
|
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")}`,
|
|
|
|
|
}), |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|