-
Notifications
You must be signed in to change notification settings - Fork 40
/
webpack.prod.js
139 lines (135 loc) · 3.86 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
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const getCompatMin = require('./compat-list')
const [ major, minor, patch ] = process.env.npm_package_compatVersion.split('.')
const [ packageMajor, packageMinor, packagePatch ] = process.env.npm_package_version.split('.')
const [ compatMinMajor, compatMinMinor ] = getCompatMin(process.env.npm_package_version)
module.exports = [
{
target: 'electron-renderer',
mode: 'production',
entry: {
renderer: path.join(__dirname, 'src/renderer/index.tsx')
},
output: {
filename: 'renderer.js',
path: path.join(__dirname, 'build')
},
node: {
__dirname: true,
__filename: false,
console: true,
fs: 'empty',
net: 'empty',
tls: 'empty'
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'production',
VERSION: process.env.npm_package_version.slice(-2) === '.0' ? process.env.npm_package_version.slice(0, process.env.npm_package_version.length - 2) : process.env.npm_package_version,
MAJOR: major,
MINOR: minor,
PATCH: patch,
PACKAGE_MAJOR: packageMajor,
PACKAGE_MINOR: packageMinor,
PACKAGE_PATCH: packagePatch,
COMPAT_MIN_MAJOR: compatMinMajor,
COMPAT_MIN_MINOR: compatMinMinor
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/renderer/template.html'
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new MiniCssExtractPlugin({
filename: 'styles/[name].[contenthash].css'
}),
],
resolve: {
extensions: [ '.ts', '.tsx', '.js', '.jsx', '.json' ]
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
// options: {
// presets: ['minify']
// }
}
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader',
options: {
limit: 25000,
prefix: path.join(__dirname, 'build')
}
},
{
test: /\.(woff|ttf)$/,
loader: 'url-loader',
options: {
limit: 25000,
prefix: path.join(__dirname, 'build')
}
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { sourceMap: true, importLoaders: 1 } },
{ loader: 'sass-loader', options: { sourceMap: true } },
]
}
]
}
},
{
target: 'electron-main',
mode: 'production',
entry: path.join(__dirname, 'src/main/index.ts'),
output: {
filename: 'index.js',
path: path.join(__dirname, 'build')
},
node: {
__dirname: false,
__filename: false
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'production',
VERSION: process.env.npm_package_version.slice(-2) === '.0' ? process.env.npm_package_version.slice(0, process.env.npm_package_version.length - 2) : process.env.npm_package_version,
MAJOR: major,
MINOR: minor,
PATCH: patch,
PACKAGE_MAJOR: packageMajor,
PACKAGE_MINOR: packageMinor,
PACKAGE_PATCH: packagePatch,
COMPAT_MIN_MAJOR: compatMinMajor,
COMPAT_MIN_MINOR: compatMinMinor
}),
new webpack.optimize.ModuleConcatenationPlugin(),
],
externals: {
winprocess: 'require(require("path").resolve(__dirname, "winprocess"))',
},
resolve: {
extensions: [ '.ts', '.js', '.json' ]
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
}
}
]