-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using NUXT.js just for static html generation with script (vendor.js, manifest.js, app,js, pages/index.js, layouts/default.js) #2822
Comments
_nuxt
scripts?
Update! This allow to not include this links.
But the problem this including nuxt system script are still open |
I have something like this in the nuxt.config file, inside the module.exports object:
You just need to install cheerio https://github.com/cheeriojs/cheerio, and add any other rule to remove other scripts |
Building off of igorify and ederchrono's solutions, I ended up with this to strip the scripts when generating static pages. In my render: { resourceHints: false },
hooks: {
'generate:page': page => {
const doc = cheerio.load(page.html);
doc(`body script`).remove();
page.html = doc.html();
},
}, |
@garredow thanks for your workaround. Since I only want to use NUXT as an HTML rendering engine it would be nice to have some options to get rid of all SPA features. |
I ended up using the prerender-spa-plugin which opens the page in a headless chromium and saves the resulting HTML to .html files. It also allows for multiple routes and so on This might be what you are looking for. I could provide example config in case anyone is interested. Nuxt is built around the idea of delivering the initial page as HTML while rendering all the following changes on the client side. Since you don't want that you might want to let go of nuxt until they allow for a pre-render option or something like that. |
This question has been resolved by @ederchrono, see answer. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi, guys! Can you anyone help me?
Does nuxt have any option to exclude
_nuxt
scripts in generate mode?I need to generate only static html version of Vue app.
Without
_nuxt
folder and included links and script.I don
t need to use javascript on client and those scripts in
_nuxt` former makes my project to heavy.Basically, I want to use NUXT just for static html generation, NOT Pre-rendering with spa on client.
<link href="/_nuxt/manifest.10d0ff23a2bf4f09b86d.js" rel="preload" as="script"><link href="/_nuxt/vendor.2c4933a76531d246be17.js" rel="preload" as="script"><link href="/_nuxt/app.b868b05b142119955871.js" rel="preload" as="script"><link href="/_nuxt/layouts/default.860485f7694926d31a51.js" rel="preload" as="script"><link href="/_nuxt/pages/index.f4640f8dc2b172dfb993.js" rel="preload" as="script"><link>
<script type="text/javascript">window.__NUXT__={layout:"default",data:[{}],error:null,serverRendered:!0}</script><script defer="" src="/_nuxt/manifest.10d0ff23a2bf4f09b86d.js"></script><script defer="" src="/_nuxt/layouts/default.860485f7694926d31a51.js"></script><script defer="" src="/_nuxt/pages/index.f4640f8dc2b172dfb993.js"></script><script defer="" src="/_nuxt/vendor.2c4933a76531d246be17.js"></script><script defer="" src="/_nuxt/app.b868b05b142119955871.js"></script>
Thanks!
The text was updated successfully, but these errors were encountered: