-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.lib.config.js
95 lines (88 loc) · 2.15 KB
/
webpack.lib.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
87
88
89
90
91
92
93
94
95
const path = require("path");
const webpack = require("webpack");
const { VueLoaderPlugin } = require("vue-loader");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const nodeExternals = require("webpack-node-externals");
const TerserPlugin = require("terser-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const packageVersion = require("./package.json").version;
const banner = `
vue3-treeselect v${packageVersion} | (c) ${new Date().getFullYear()} Andreas Johansson
Released under the MIT License.
https://vue3-treeselect.js.org/
`.trim();
const baseConfig = {
entry: "./src/index.js",
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: "vue3-treeselect.min.css",
chunkFilename: "[id].css"
}),
new webpack.DefinePlugin({
PKG_VERSION: JSON.stringify(packageVersion)
}),
new webpack.BannerPlugin(banner)
],
optimization: {
concatenateModules: true,
emitOnErrors: false,
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
terserOptions: {
sourceMap: false
}
}),
new CssMinimizerPlugin()
]
},
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.vue$/,
loader: "vue-loader",
options: {
babelParserPlugins: ["jsx", "classProperties", "decorators-legacy"]
}
},
{
test: /\.(js|jsx)$/,
use: {
loader: "babel-loader",
options: {
plugins: ["@vue/babel-plugin-jsx"]
}
}
},
{
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"]
},
{
test: /\.(png|jpg|jpeg|ico)/,
type: "asset/inline"
}
]
}
};
module.exports = [
{
...baseConfig,
output: {
path: path.join(__dirname, "dist/"),
libraryTarget: "commonjs2",
filename: "vue3-treeselect.cjs.min.js"
}
},
{
...baseConfig,
output: {
path: path.join(__dirname, "dist/"),
libraryTarget: "umd",
filename: "vue3-treeselect.umd.min.js"
}
}
];