forked from Zettlr/Zettlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (64 loc) · 2.02 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
// webpack.config.js
const VueLoaderPlugin = require('vue-loader/lib/plugin')
// MiniCssExtractPlugin generates the necessary CSS files for
// our components.
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const path = require('path')
module.exports = {
entry: {
sidebar: './resources/vue/sidebar.js'
},
target: 'electron-renderer',
mode: process.env.NODE_ENV,
devtool: 'none', // Don't use fancy packing which breaks Electron's content policy.
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: [
// AFTER 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$/,
loader: 'vue-loader'
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: false // Disable hot module reloading
}
},
'css-loader'
]
}
]
},
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 MiniCssExtractPlugin({
// The files will be placed next to the respective components
// i.e.: vue-sidebar.js will be in the same directory as sidebar.css
filename: '[name].css',
ignoreOrder: false // Maybe we need this if the plugin spits out warnings
})
]
}