-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.build.config.js
More file actions
124 lines (121 loc) · 2.6 KB
/
webpack.build.config.js
File metadata and controls
124 lines (121 loc) · 2.6 KB
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
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const JavaScriptObfuscator = require('webpack-obfuscator');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const mainConfig = {
mode: 'production',
target: 'electron-main',
entry: { main: './app/main.js', vendor: ['firebase'] },
output: {
path: __dirname + '/webpack-pack',
filename: '[name].js'
},
node: {
__dirname: false,
__filename: false
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
presets: 'minify',
plugins: ['emotion']
},
exclude: /node_modules/
},
{
test: /\.js$/,
include: [path.resolve(__dirname, '/app')],
enforce: 'post',
use: {
loader: 'obfuscator-loader'
}
}
]
},
plugins: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false,
beautify: false
}
}
}),
new JavaScriptObfuscator()
],
resolve: {
extensions: ['.js', '.json', '.jsx']
}
};
const appConfig = {
mode: 'production',
target: 'electron-renderer',
entry: './app/app.js',
output: {
path: __dirname + '/webpack-pack',
filename: 'app.js'
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
presets: 'minify'
},
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(jpe?g|png|gif)$/,
use: [{ loader: 'file-loader?name=/img/[name]__[hash:base64:5].[ext]' }]
},
{
test: /\.(svg)$/,
use: [
{
loader: 'file-loader?name=/files/[name]__[hash:base64:5].[ext]',
options: {
useRelativePath: true
}
}
]
},
{ test: /\.(png|woff|woff2|eot|ttf)$/, loader: 'url-loader?limit=100000' }
]
},
plugins: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
comments: false,
beautify: false
}
}
}),
new HtmlWebpackPlugin({
title: 'Photon',
template: './app/index.html',
inject: false
}),
new JavaScriptObfuscator(),
new CopyWebpackPlugin([
{
from: './app/img/icon.png',
to: './',
toType: 'dir'
}
])
],
resolve: {
extensions: ['.js', '.json', '.jsx']
}
};
module.exports = [mainConfig, appConfig];