forked from Zettlr/Zettlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
81 lines (77 loc) · 2.09 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
// webpack.config.js
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const path = require('path')
const webpack = require('webpack')
var configuration = {
entry: {
sidebar: './resources/vue/sidebar.js'
},
target: 'electron-renderer',
mode: process.env.NODE_ENV,
devtool: 'cheap-module-source-map',
output: {
filename: 'vue-[name].js',
// The target is commonJS so that we can require() the entry points.
libraryTarget: 'commonjs2',
// Place the app in the assets directory
path: path.resolve(__dirname, 'source/renderer/assets/vue'),
// The common/assets folder is the default publicPath
publicPath: path.resolve(__dirname, 'source/common/assets')
},
module: {
rules: [
{
test: /\.(js|vue)$/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'eslint-loader'
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
},
// BEFORE this rule we can add any other rules we may have,
// b/c vue-loader will split up vue files in three chunks.
// --> CSS, JS, and the render function (so, basically JS)
// (Nota bene: Webpack parses bottom-up, so new rules need
// to be placed ABOVE this one.)
{
test: /\.vue$/,
use: {
loader: 'vue-loader',
options: {
extractCSS: process.env.NODE_ENV === 'production'
}
}
}
]
},
resolve: {
alias: {
// We need to explicitly use the commonJS-version of VueJS
// to work with stuff like module.exports and require().
'vue$': 'vue/dist/vue.common.js'
}
},
plugins: [
new VueLoaderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
]
}
if (process.env.NODE_ENV === 'production') {
// Don't emit sourcemaps
configuration.devtool = ''
configuration.plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
)
}
module.exports = configuration