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.
91 lines
2.8 KiB
91 lines
2.8 KiB
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(); |
|
} |
|
|
|
let lessVariables = {}; |
|
|
|
if (process.env.LESS_CONFIG_PATH) { |
|
const lessConfigPath = path.isAbsolute(process.env.LESS_CONFIG_PATH) |
|
? process.env.LESS_CONFIG_PATH |
|
: path.resolve(__dirname, "lessconfig", process.env.LESS_CONFIG_PATH); |
|
|
|
lessVariables = fs.existsSync(lessConfigPath) ? require(lessConfigPath) || {} : {}; |
|
} |
|
|
|
module.exports = { |
|
mode: "production", |
|
entry: { |
|
"fineui.min": "./src/bundle.js", |
|
}, |
|
output: { |
|
path: path.resolve(__dirname, "dist"), |
|
filename: "[name].js", |
|
}, |
|
devtool: "hidden-source-map", |
|
module: { |
|
rules: [ |
|
{ |
|
test: /\.js$/, |
|
exclude: /node_modules/, |
|
use: { |
|
loader: "babel-loader", |
|
}, |
|
}, |
|
{ |
|
test: /\.(css|less)$/, |
|
use: [ |
|
MiniCssExtractPlugin.loader, |
|
{ |
|
loader: "css-loader", |
|
options: { |
|
url: false, |
|
}, |
|
}, |
|
{ |
|
loader: "postcss-loader", |
|
options: { |
|
plugins: [autoprefixer], |
|
}, |
|
}, |
|
{ |
|
loader: "less-loader", |
|
options: { |
|
relativeUrls: false, |
|
modifyVars: lessVariables, |
|
}, |
|
}, |
|
], |
|
}, |
|
], |
|
}, |
|
resolve: { |
|
extensions: [".js", ".ts"], |
|
alias: { |
|
"@": path.resolve(__dirname, "src"), |
|
}, |
|
}, |
|
plugins: [new CircularDependencyPlugin()], |
|
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")}`, |
|
}), |
|
], |
|
}, |
|
};
|
|
|