Skip to content

Commit e1f22ac

Browse files
committed
Enable production sourcemap for index.js, fix css sourcemaps
1 parent eab20cb commit e1f22ac

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

docs/content/installation/from-source.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ If pre-built frontend files are present it is possible to only build the backend
128128
TAGS="bindata" make backend
129129
```
130130

131-
Webpack source maps are by default enabled in development builds and disabled in production builds. They can be enabled by setting the `ENABLE_SOURCEMAP=true` environment variable.
131+
Webpack source maps are limited by default to conserve space. When `ENABLE_SOURCEMAP=true` is set, the webpack build will generate all source maps.
132132

133133
## Test
134134

docs/content/installation/from-source.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ TAGS="bindata sqlite sqlite_unlock_notify" make build
100100
TAGS="bindata" make backend
101101
```
102102

103-
在开发构建中,默认启用 Webpack 源映射,在生产构建中禁用。可以通过设置`ENABLE_SOURCEMAP=true`环境变量来启用它们
103+
默认情况下,Webpack 源映射受到限制以节省空间。 当设置`ENABLE_SOURCEMAP=true`时,webpack 构建将生成所有源映射
104104

105105
## 测试
106106

webpack.config.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ for (const path of glob('web_src/css/themes/*.css')) {
2828

2929
const isProduction = env.NODE_ENV !== 'development';
3030

31-
let sourceMapEnabled;
31+
// The production build only generates limited sourcemaps to conserve binary size.
32+
// When in development or when ENABLE_SOURCEMAP=true, generate all source maps.
33+
let fullSourceMapEnabled;
3234
if ('ENABLE_SOURCEMAP' in env) {
33-
sourceMapEnabled = env.ENABLE_SOURCEMAP === 'true';
35+
fullSourceMapEnabled = env.ENABLE_SOURCEMAP === 'true';
3436
} else {
35-
sourceMapEnabled = !isProduction;
37+
fullSourceMapEnabled = !isProduction;
3638
}
3739

3840
const filterCssImport = (url, ...args) => {
@@ -105,7 +107,9 @@ export default {
105107
css: !LightningCssMinifyPlugin,
106108
legalComments: 'none',
107109
}),
108-
LightningCssMinifyPlugin && new LightningCssMinifyPlugin(),
110+
LightningCssMinifyPlugin && new LightningCssMinifyPlugin({
111+
sourceMap: fullSourceMapEnabled,
112+
}),
109113
],
110114
splitChunks: {
111115
chunks: 'async',
@@ -143,7 +147,7 @@ export default {
143147
{
144148
loader: 'css-loader',
145149
options: {
146-
sourceMap: sourceMapEnabled,
150+
sourceMap: fullSourceMapEnabled,
147151
url: {filter: filterCssImport},
148152
import: {filter: filterCssImport},
149153
},
@@ -181,9 +185,10 @@ export default {
181185
filename: 'css/[name].css',
182186
chunkFilename: 'css/[name].[contenthash:8].css',
183187
}),
184-
sourceMapEnabled && (new SourceMapDevToolPlugin({
188+
new SourceMapDevToolPlugin({
185189
filename: '[file].[contenthash:8].map',
186-
})),
190+
...(!fullSourceMapEnabled && {include: /^js\/index\.js$/}),
191+
}),
187192
new MonacoWebpackPlugin({
188193
filename: 'js/monaco-[name].[contenthash:8].worker.js',
189194
}),

0 commit comments

Comments
 (0)