forked from Zettlr/Zettlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.renderer.config.js
71 lines (66 loc) · 2.35 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
const rules = require('./webpack.rules')
const path = require('path')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
const { DefinePlugin } = require('webpack')
rules.push({
test: /\.less$/,
use: [{
loader: 'style-loader' // Create style nodes from JS strings
}, {
loader: '@teamsupercell/typings-for-css-modules-loader' // Enrich css by typing information
}, {
loader: 'css-loader' // Translate CSS into JS string
}, {
loader: 'less-loader' // Compile Less to CSS
}],
exclude: /theme-main\.less$/
})
rules.push({
test: /theme-main\.less$/, // The themes need to be imported differently
use: [{
loader: 'style-loader', // Create style nodes from JS strings
options: { injectType: 'lazyStyleTag' } // Lazy-load themes so that we can switch between them
}, {
loader: '@teamsupercell/typings-for-css-modules-loader' // Enrich css by typing information
}, {
loader: 'css-loader' // Translate CSS into JS string
}, {
loader: 'less-loader' // Compile Less to CSS
}]
})
module.exports = {
module: { rules },
// The following line of code serves two purposes: While we're in develop
// (NODE_ENV = develop), emit source maps so we have an easy time finding the
// origin of bugs or performance bottlenecks. But since source maps are a
// whopping 60MB large at the time of writing (July 2021), we disable these
// in production (i.e. when we ship to users). NOTE, however, that these env-
// variables must be set, which we're doing using cross-env in package.json.
devtool: (process.env.NODE_ENV === 'production') ? false : 'source-map',
plugins: [
// Enhanced typescript support (e.g. moves typescript type checking to separate process)
new ForkTsCheckerWebpackPlugin(),
// Apply webpack rules to the corresponding language blocks in .vue files
new VueLoaderPlugin(),
// Set a few Vue 3 options; see: http://link.vuejs.org/feature-flags
new DefinePlugin({
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false
})
],
resolve: {
extensions: [
'.js', '.ts', '.jsx', '.tsx',
'.css', '.less', '.vue'
],
alias: {
'@common': [path.resolve(__dirname, 'source/common')]
},
fallback: {
// Don't polyfill these modules
path: false,
fs: false
}
}
}