more build options

This commit is contained in:
notgne2 2019-12-12 16:44:46 -07:00
parent e0e3b70e78
commit c92290bdd9
3 changed files with 6488 additions and 4 deletions

6453
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@
"jsdom": "^15.2.1",
"prerender-spa-plugin": "^3.4.0",
"tempy": "^0.3.0",
"terser-webpack-plugin": "^2.3.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"workbox-webpack-plugin": "^4.3.1"
@ -19,4 +20,4 @@
"author": "notgne2",
"license": "AGPL-3.0",
"description": ""
}
}

View File

@ -1,4 +1,5 @@
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const PrerenderSPAPlugin = require('prerender-spa-plugin')
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
@ -16,6 +17,16 @@ const magicFile = (text) => {
// const magicAppend = (orig, text, sep = '\n') => magicFile(fs.readFileSync(orig) + sep + text)
const jsMin = {
pure_funcs: ["F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9"],
pure_getters: true,
keep_fargs: false,
unsafe_comps: true,
unsafe: true,
compress: true,
mangle: true,
}
module.exports =
{
module: {
@ -26,15 +37,34 @@ module.exports =
}],
},
plugins: [
new HtmlWebpackPlugin(),
new TerserPlugin({
terserOptions: jsMin,
}),
new HtmlWebpackPlugin({
hash: true,
meta: {
viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'
}
}),
new CopyPlugin([{ from: 'data', to: 'data' }, { from: 'wand.js', to: 'wand.js' }]),
new PrerenderSPAPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: ROUTES,
minify: {
minifyCSS: true,
minifyJS: true,
minifyCSS: {
compatibility: 'ie9',
level: 2
},
minifyJS: jsMin,
removeComments: true,
collapseBooleanAttributes: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
sortAttributes: true,
sortClassName: true,
},
renderer: new Renderer(),
postProcess(renderedRoute) {