Remove scripts from all pages

This commit is contained in:
Sam Carlton 2021-09-04 16:48:08 -05:00
parent c602aa9de8
commit 7165f4db3c

View file

@ -3,6 +3,8 @@ import { promises as fs } from 'fs'
import pkg from './package'
const removeAllScripts = html => html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '')
export default {
target: 'static',
@ -17,6 +19,14 @@ export default {
* https://nuxtjs.org/api/configuration-hooks/
*/
hooks: {
// This hook is called before generatic static html files for SPA mode
'generate:page': (page) => {
page.html = removeAllScripts(page.html)
},
// This hook is called before rendering the html to the browser
'render:route': (url, page, { req, res }) => {
page.html = removeAllScripts(page.html)
}
// build: {
// before: storeAppLists
// },
@ -165,7 +175,7 @@ export default {
// Always run
// Push meta import rule for zip.js
config.module.rules.push({
test: /\.js$/,