forked from Happy-Coding-Clans/vue-easytable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.comps.config.js
86 lines (75 loc) · 2.38 KB
/
webpack.comps.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
编译输出每个组件
*/
const path = require("path");
const webpack = require("webpack");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ProgressBarPlugin = require("progress-bar-webpack-plugin");
const Components = require("../components.json");
//const TerserPlugin = require("terser-webpack-plugin");
const config = require("./config");
module.exports = function (env) {
return {
mode: "production",
entry: Components,
output: {
path: path.join(__dirname, "../libs"),
filename: "[name].js",
chunkFilename: "[id].js",
/*
commonjs 分配给 exports 对象;
commonjs2 分配给 module.exports 对象;
*/
libraryTarget: "commonjs2",
},
optimization: {
minimize: true,
},
resolve: {
extensions: [".js", ".jsx", ".vue", ".json"],
modules: [path.resolve("./node_modules")],
alias: config.alias,
},
externals: config.externals,
module: {
rules: [
// babel-loader
{
test: /\.(js|jsx)$/,
use: "babel-loader",
exclude: /node_modules/,
},
// vue loader
{
test: /\.vue$/,
use: [
{
loader: "vue-loader",
options: {
compilerOptions: {
preserveWhitespace: false,
},
},
},
],
},
{
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
loader: "url-loader",
query: {
limit: 10000,
name: path.posix.join(
"static",
"[name].[hash:7].[ext]",
),
},
},
],
},
plugins: [new ProgressBarPlugin(), new VueLoaderPlugin()],
performance: {
hints: "warning",
},
};
};