This repository has been archived by the owner on Jan 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
117 lines (113 loc) · 3.46 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const path = require("path");
const fs = require('fs');
const glob = require("glob");
const context = path.resolve(__dirname, "build");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const yarnPackage = require("./package.json");
$entries = {'index':'./src/index.js'};
/**
Webpack Export
**/
module.exports = {
mode: 'production',
devtool:'source-map',
target: "electron-renderer",
entry: $entries,
output: {
path: path.resolve(__dirname, "build"),
filename: "js/[name].js"
},
devServer: {
contentBase: path.join(__dirname, "build"),
compress: true,
port: 9000,
hot: false,
open: false,
inline: false,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
},
stats: "minimal"
},
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
},
{
test: /\.(ttf|eot|svg|otf|woff(2)?)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
plugins: [
'transform-react-jsx',
'transform-class-properties',
['react-css-modules',
{
generateScopedName: 'style-[name]-[local]',
context:context,
filetypes: {
'.less': {syntax: 'postcss-less'}
}
}
],
]
}
},
{
test: /\.(jsx|js)$/,
exclude: /node_modules/,
loader: 'eslint-loader',
}
]
},
plugins: [
new MiniCssExtractPlugin({
verbose:false,
filename: 'css/[name].css'
}),
new CopyWebpackPlugin([
{from: '**/*', to: './', context:'./src/public/electron'},
{from: '**/*', to: './', context:'./src/public/shared'}
], {}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(yarnPackage.version)
})
],
externals: {
bindings: true,
serialport: true,
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: "all"
}
}
}
}
};