feat: add debug build (#1506)
This commit is contained in:
parent
5332a4e1e9
commit
b32be27cf7
|
@ -143,6 +143,12 @@ Pinafore also offers a "legacy" build designed for older browsers. To build this
|
||||||
|
|
||||||
LEGACY=1 yarn build
|
LEGACY=1 yarn build
|
||||||
|
|
||||||
|
## Debug build
|
||||||
|
|
||||||
|
To disable minification in a production build (for debugging purposes), you can run:
|
||||||
|
|
||||||
|
DEBUG=1 yarn build
|
||||||
|
|
||||||
## Debugging Webpack
|
## Debugging Webpack
|
||||||
|
|
||||||
The Webpack Bundle Analyzer `report.html` and `stats.json` are available publicly via e.g.:
|
The Webpack Bundle Analyzer `report.html` and `stats.json` are available publicly via e.g.:
|
||||||
|
|
|
@ -21,13 +21,14 @@ export async function buildInlineScript () {
|
||||||
plugins: [
|
plugins: [
|
||||||
replace({
|
replace({
|
||||||
'process.browser': true,
|
'process.browser': true,
|
||||||
|
'process.env.LEGACY': JSON.stringify(process.env.LEGACY),
|
||||||
'process.env.THEME_COLORS': JSON.stringify(themeColors)
|
'process.env.THEME_COLORS': JSON.stringify(themeColors)
|
||||||
}),
|
}),
|
||||||
process.env.LEGACY && babel({
|
process.env.LEGACY && babel({
|
||||||
runtimeHelpers: true,
|
runtimeHelpers: true,
|
||||||
presets: ['@babel/preset-env']
|
presets: ['@babel/preset-env']
|
||||||
}),
|
}),
|
||||||
terser({
|
!process.env.DEBUG && terser({
|
||||||
mangle: true,
|
mangle: true,
|
||||||
compress: true,
|
compress: true,
|
||||||
ecma: 8
|
ecma: 8
|
||||||
|
|
|
@ -88,7 +88,7 @@ module.exports = {
|
||||||
optimization: dev ? {} : {
|
optimization: dev ? {} : {
|
||||||
minimizer: [
|
minimizer: [
|
||||||
terser()
|
terser()
|
||||||
],
|
].filter(Boolean),
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
chunks: 'async',
|
chunks: 'async',
|
||||||
minSize: 5000,
|
minSize: 5000,
|
||||||
|
@ -130,7 +130,7 @@ module.exports = {
|
||||||
]),
|
]),
|
||||||
devtool: dev ? 'inline-source-map' : 'source-map',
|
devtool: dev ? 'inline-source-map' : 'source-map',
|
||||||
performance: {
|
performance: {
|
||||||
hints: dev ? false : 'error',
|
hints: dev ? false : (process.env.DEBUG ? 'warning' : 'error'),
|
||||||
assetFilter: assetFilename => {
|
assetFilter: assetFilename => {
|
||||||
return !(/\.map$/.test(assetFilename)) && !/tesseract-asset/.test(assetFilename)
|
return !(/\.map$/.test(assetFilename)) && !/tesseract-asset/.test(assetFilename)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,5 @@ module.exports = {
|
||||||
'process.env.SAPPER_TIMESTAMP': process.env.SAPPER_TIMESTAMP || Date.now()
|
'process.env.SAPPER_TIMESTAMP': process.env.SAPPER_TIMESTAMP || Date.now()
|
||||||
}),
|
}),
|
||||||
terser()
|
terser()
|
||||||
]
|
].filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const TerserWebpackPlugin = require('terser-webpack-plugin')
|
const TerserWebpackPlugin = require('terser-webpack-plugin')
|
||||||
|
|
||||||
module.exports = () => new TerserWebpackPlugin({
|
module.exports = () => !process.env.DEBUG && new TerserWebpackPlugin({
|
||||||
exclude: /tesseract-asset/,
|
exclude: /tesseract-asset/,
|
||||||
cache: true,
|
cache: true,
|
||||||
parallel: true,
|
parallel: true,
|
||||||
|
|
Loading…
Reference in New Issue