forked from Pr-Mex/VAEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
123 lines (122 loc) · 3.17 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
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
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const path = require('path')
const webpack = require('webpack')
const nls = require.resolve('monaco-editor-nls')
module.exports = (env, argv) => {
return {
entry: {
app: './src/main',
test: './test/autotest.js'
},
resolve: {
extensions: ['.ts', '.js', '.css']
},
output: {
globalObject: 'self',
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
resolveLoader: {
alias: {
'blob-url-loader': require.resolve('./tools/loaders/blobUrl'),
'compile-loader': require.resolve('./tools/loaders/compile'),
'monaco-nls': require.resolve('./tools/loaders/monacoNls')
}
},
module: {
rules: [
{
test: /node_modules[\\/]monaco-editor-nls[\\/].+\.js$/,
loader: 'string-replace-loader',
options: {
multiple: [{
search: 'let CURRENT_LOCALE_DATA = null;',
replace: 'var CURRENT_LOCALE_DATA = null;'
}]
}
},
{
test: /node_modules[\\/]monaco-editor[\\/]esm[\\/].+\.js$/,
loader: 'string-replace-loader',
options: {
multiple: [{
search: 'let __insane_func;',
replace: 'var __insane_func;'
}]
}
},
{
test: /node_modules[\\/]monaco-editor[\\/]esm[\\/].+\.js$/,
loader: 'string-replace-loader',
options: {
multiple: [{
search: 'secondary: [2048 /* CtrlCmd */ | 39 /* KeyI */],',
replace: 'secondary: null,'
}]
}
},
{
test: /\.js$/,
enforce: 'pre',
include: /node_modules[\\/]monaco-editor[\\/]esm/,
use: 'monaco-nls'
},
{
test: /\.ts$/,
use: [
'babel-loader',
'ts-loader'
]
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
'postcss-loader'
]
},
{
test: /\.feature$/,
use: 'raw-loader'
},
{
test: /\.txt$/,
use: 'raw-loader'
}]
},
plugins: [
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env),
'process.argv': JSON.stringify(argv)
}),
new webpack.NormalModuleReplacementPlugin(/\/(vscode-)?nls\.js$/, function (resource) {
resource.request = nls
resource.resource = nls
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'VAEditor',
cache: false
}),
new ScriptExtHtmlWebpackPlugin({
inline: [
'app.js'
]
})
],
optimization: {
minimize: argv.mode === 'production'
},
devServer: {
port: 4000,
hot: argv.mode === 'development',
open: true
}
}
}