feat: add debug build (#1506)

This commit is contained in:
Nolan Lawson 2019-09-21 13:44:32 -07:00 committed by GitHub
parent 5332a4e1e9
commit b32be27cf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 5 deletions

View File

@ -143,6 +143,12 @@ Pinafore also offers a "legacy" build designed for older browsers. To build this
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
The Webpack Bundle Analyzer `report.html` and `stats.json` are available publicly via e.g.:

View File

@ -21,13 +21,14 @@ export async function buildInlineScript () {
plugins: [
replace({
'process.browser': true,
'process.env.LEGACY': JSON.stringify(process.env.LEGACY),
'process.env.THEME_COLORS': JSON.stringify(themeColors)
}),
process.env.LEGACY && babel({
runtimeHelpers: true,
presets: ['@babel/preset-env']
}),
terser({
!process.env.DEBUG && terser({
mangle: true,
compress: true,
ecma: 8

View File

@ -88,7 +88,7 @@ module.exports = {
optimization: dev ? {} : {
minimizer: [
terser()
],
].filter(Boolean),
splitChunks: {
chunks: 'async',
minSize: 5000,
@ -130,7 +130,7 @@ module.exports = {
]),
devtool: dev ? 'inline-source-map' : 'source-map',
performance: {
hints: dev ? false : 'error',
hints: dev ? false : (process.env.DEBUG ? 'warning' : 'error'),
assetFilter: assetFilename => {
return !(/\.map$/.test(assetFilename)) && !/tesseract-asset/.test(assetFilename)
}

View File

@ -23,5 +23,5 @@ module.exports = {
'process.env.SAPPER_TIMESTAMP': process.env.SAPPER_TIMESTAMP || Date.now()
}),
terser()
]
].filter(Boolean)
}

View File

@ -1,6 +1,6 @@
const TerserWebpackPlugin = require('terser-webpack-plugin')
module.exports = () => new TerserWebpackPlugin({
module.exports = () => !process.env.DEBUG && new TerserWebpackPlugin({
exclude: /tesseract-asset/,
cache: true,
parallel: true,