-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.prod.js
159 lines (157 loc) · 3.74 KB
/
webpack.prod.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
global.dirname = __dirname;
module.exports = env => ({
target: 'electron-renderer',
mode: 'production',
devtool: 'source-map',
entry: {
app: path.join(__dirname, 'app/container/index.jsx'),
preload: path.join(__dirname, 'app/container/preload.js'),
},
resolve: {
extensions: ['.js', '.jsx', '.mjs', '.wasm', '.json'],
},
output: {
path: path.resolve(__dirname, 'lib'),
publicPath: './',
filename: '[name].prod.js',
},
plugins: [
new HtmlWebpackPlugin({
template: 'app/container/index.tpl.html',
inject: 'body',
filename: 'index.html',
excludeChunks: ['preload'],
}),
],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: false,
cacheDirectory: false,
presets: [
[
'@babel/preset-env',
{
targets: {
electron: '3.0.2',
},
modules: false,
useBuiltIns: 'entry',
},
],
[
'@babel/preset-react',
{
development: (!env || !env.NODE_ENV)
? 'development'
: env.NODE_ENV.toLowerCase() === 'development',
},
],
'@babel/preset-flow',
],
plugins: [
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-class-properties',
[
// used only for babel helpers
'@babel/plugin-transform-runtime',
{
// regenerator runtime should be used from global polyfill
regenerator: false,
// define babel helpers as es modules
useESModules: true,
},
],
[
'babel-plugin-styled-components',
{
displayName: true,
},
],
],
env: {
development: {
plugins: [
'react-hot-loader/babel',
],
},
},
},
},
},
{
test: /\.(css)$/,
use: [
'style-loader',
'css-loader',
],
},
{
test: /\.(less)$/,
use: [
'style-loader',
'css-loader',
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
},
},
],
},
// WOFF/WOFF2 Fonts
{
test: /\.woff(.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff',
},
},
},
// TTF Fonts
{
test: /\.ttf(.*)?$/,
use: {
loader: 'file-loader',
options: {
limit: 10000,
name: '/fonts/[name].[ext]',
},
},
},
// SVG
{
test: /\.svg(.*)?$/,
use: {
loader: 'svg-inline-loader',
},
},
// Common Image Formats
{
test: /\.(?:ico|gif|png|jpg|jpeg|eot|webp)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
],
},
],
},
node: {
__dirname: false,
__filename: false,
},
});