-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.js
46 lines (43 loc) · 1.02 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require("webpack");
var config = {
entry: "./src/index.ts",
optimization: {
minimize: true,
},
module: {
rules: [
{
test: /\.ts?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"],
},
],
},
resolve: {
extensions: [".ts", ".js"],
},
output: {
filename: "index.js",
path: path.resolve(__dirname, "dist"),
},
plugins: [
new MiniCssExtractPlugin({
filename: "index.wxss", // 打包后从js文件中提取出来的css文件名称
}),
],
};
module.exports = (env, argv) => {
if (argv.mode === "development") {
config.devtool = "inline-source-map";
} else if (argv.mode === "none") {
config.output.libraryTarget = "umd";
config.output.globalObject = "typeof self !== 'undefined' ? self : this";
}
return config;
};