forked from luniehq/lunie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.renderer.config.js
147 lines (139 loc) · 3.79 KB
/
webpack.renderer.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
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
"use strict"
process.env.BABEL_ENV = "renderer"
const path = require("path")
const webpack = require("webpack")
const stylus = require("stylus")
const fs = require("fs-extra")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const VueLoaderPlugin = require("vue-loader/lib/plugin")
function resolve(dir) {
return path.join(__dirname, dir)
}
let rendererConfig = {
devtool: "#eval-source-map",
entry: {
renderer: path.join(__dirname, "app/src/renderer/main.js")
},
module: {
rules: [
{
test: /\.js$/,
use: "babel-loader",
include: [path.resolve(__dirname, "app/src/renderer")],
exclude: /node_modules/
},
{
test: /\.json$/,
use: "json-loader"
},
{
test: /\.vue$/,
use: {
loader: "vue-loader"
}
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
use: [
{
loader: "url-loader",
query: {
limit: 10000,
name: "imgs/[name].[ext]"
}
}
]
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
use: [
{
loader: "url-loader",
query: {
limit: 10000,
name: "fonts/[name].[ext]"
}
}
]
},
{
test: /\.pug$/,
loader: "pug-plain-loader"
},
{
test: /\.styl(us)?$/,
use: ["vue-style-loader", "css-loader", "stylus-loader"]
}
]
},
node: {
__dirname: false,
__filename: false
},
plugins: [
new VueLoaderPlugin(),
// the global.GENTLY below fixes a compile issue with superagent + webpack
// https://github.com/visionmedia/superagent/issues/672
new webpack.DefinePlugin({ "global.GENTLY": false }),
new HtmlWebpackPlugin({
filename: "index.html",
template: "./app/index.ejs",
appModules:
process.env.NODE_ENV !== "production"
? path.resolve(__dirname, "app/node_modules")
: false,
styles: stylus(
fs.readFileSync("./app/src/renderer/styles/index.styl", "utf8")
)
.import("./app/src/renderer/styles/variables.styl")
.render()
}),
new webpack.NoEmitOnErrorsPlugin(),
// warnings caused by websocket-stream, which has a server-part that is unavailable on the the client
new webpack.IgnorePlugin(/(bufferutil|utf-8-validate)/),
// put all modules in node_modules in chunk
new webpack.optimize.CommonsChunkPlugin({
name: "vendor"
})
],
output: {
filename: "[name].js",
libraryTarget: "commonjs2",
path: path.join(__dirname, "app/dist")
},
resolve: {
alias: {
renderer: resolve("app/src/renderer"),
"@": resolve("app/src/renderer"),
assets: resolve("app/src/renderer/assets"),
scripts: resolve("app/src/renderer/scripts"),
common: resolve("app/src/renderer/components/common"),
govern: resolve("app/src/renderer/components/govern"),
monitor: resolve("app/src/renderer/components/monitor"),
staking: resolve("app/src/renderer/components/staking"),
wallet: resolve("app/src/renderer/components/wallet"),
variables: resolve("app/src/renderer/styles/variables.styl")
},
extensions: [".js", ".vue", ".json", ".css", ".node", ".styl"],
modules: [
path.join(__dirname, "app/node_modules"),
path.join(__dirname, "node_modules")
]
},
target: "electron-renderer"
}
/**
* Adjust rendererConfig for production settings
*/
if (process.env.NODE_ENV === "production") {
rendererConfig.devtool = ""
rendererConfig.plugins.push(
new webpack.DefinePlugin({
"process.env.NODE_ENV": '"production"'
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
)
}
module.exports = rendererConfig