-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.extra-config.js
73 lines (71 loc) · 2.31 KB
/
webpack.extra-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
const HtmlWebpackPlugin = require("html-webpack-plugin");
const merge = require("webpack-merge");
const { compact } = require("lodash");
module.exports = config => {
config.devtool = process.env.NODE_ENV === "development" ? "eval" : "";
let cssRules;
if (process.env.NODE_ENV === "development") {
config.module.rules = config.module.rules.map(rule => {
if (rule.use && rule.use[0] === "css-hot-loader") {
// do nothing
} else {
return rule;
}
});
cssRules = [
{
test: /\.?css$/,
use: [
"vue-style-loader",
{ loader: "css-loader", options: { importLoaders: 1 } },
"postcss-loader"
]
}
];
} else {
config.module.rules = config.module.rules.map(rule => {
try {
if (rule.use && rule.use[0].match("mini-css-extract-plugin")) {
// do nothing
} else {
return rule;
}
} catch (error) {
return rule;
}
});
cssRules = [
{
test: /\.?css$/,
use: [
"css-hot-loader",
"vue-style-loader",
// "/Users/mlarosa/src/pdsc/pdsc-eaf-viewer/node_modules/electron-webpack/node_modules/mini-css-extract-plugin/dist/loader.js",
{ loader: "css-loader", options: { importLoaders: 1 } },
"postcss-loader"
]
}
];
}
config.module.rules = compact(config.module.rules);
config.module.rules.push(...cssRules);
config = merge(config, {
resolve: {
alias: {
src: `${__dirname}/src`,
assets: `${__dirname}/src/assets`,
components: `${__dirname}/src/components`,
node_modules: `${__dirname}/node_modules`
}
},
plugins: [
new HtmlWebpackPlugin({
title: "EAF Viewer",
template: "src/renderer/index.html",
hash: true
})
]
});
// console.log(JSON.stringify(config, null, 2));
return config;
};