-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
66 lines (66 loc) · 1.64 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const path = require("path");
// const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const webpack = require("webpack");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const pkg = require("./package.json");
const MinifyPlugin = require("babel-minify-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = (env = {}) => {
const isProd = env.production;
let corePlugins = [];
if (isProd) {
corePlugins = [new webpack.BannerPlugin(`${pkg.name} - ${pkg.version}`), new MinifyPlugin({},{})];
}
const index = "index.html";
const indexDev = "_" + index;
corePlugins.push(
new HtmlWebpackPlugin({
template: isProd? index : indexDev,
inject: false,
}),
);
return {
mode: isProd ? "production" : "development",
devtool: isProd ? "source-map" : "cheap-module-eval-source-map",
entry: {
"grapesjs-echarts": "./src",
"grapesjs-echarts.min": "./src",
},
output: {
path: path.resolve(__dirname),
filename: "dist/[name].js",
chunkFilename: "dist/[name].bundle.js",
library: pkg.name,
libraryTarget: "umd",
},
module: {
rules: [
{
test: /\.svg$/,
loader: "svg-inline-loader"
},
{
test: /\.vue$/,
loader: "vue-loader",
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
include: /src/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
},
{
test: /\.scss$/,
use: ["vue-style-loader", "css-loader", "sass-loader"],
},
],
},
plugins: [...corePlugins, new VueLoaderPlugin()],
externals: { grapesjs: "grapesjs" },
};
};