-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
98 lines (94 loc) · 3.09 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
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
96
97
98
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin")
module.exports = (env, _) => {
const source = path.resolve(__dirname, "src/SoundDeck.PI");
const dest = env.dist
? path.resolve(__dirname, "dist/com.geekyeggo.sounddeck.sdPlugin/PI")
: path.resolve(process.env["APPDATA"], "Elgato/StreamDeck/Plugins/com.geekyeggo.sounddeck.sdPlugin/PI");
let config = {
entry: {
index: path.resolve(source, "js/index.jsx")
},
module: {
rules: [{
test: /\.css$/,
use: [
{ loader: "style-loader/url" },
{
loader: "file-loader",
options: {
name: "./css/[name].css"
}
}],
}, {
test: /\.jsx$/,
include: source,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-react"]
}
}
}]
},
output: {
filename: "./js/[name].js",
path: dest
},
plugins: [
new CleanWebpackPlugin({
cleanAfterEveryBuildPatterns: ["!*.html", "!css/**/*.*", "!imgs/**/*.*"],
}),
new CopyPlugin({
patterns: [
{
from: source,
to: dest,
context: source,
globOptions: {
ignore: [
"**/bin",
"**/obj",
"**/.babelrc",
"**/*.csproj",
"**/*.csproj*",
"**/*.jsx"
]
}
}
]
})
],
resolve: {
extensions: [".js", ".jsx"],
alias: {
react: path.resolve("./node_modules/react"),
"react-dom": path.resolve("./node_modules/react-dom"),
"react-redux": path.resolve("./node_modules/react-redux")
},
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: "all",
name: "vendor",
enforce: true,
priority: -1
}
}
}
},
watchOptions: {
ignored: ['**/node_modules'],
}
};
// set the dev tool
if (!env.dist) {
config.devtool = "inline-source-map";
}
return config;
};