nuxt-build-optimisations
Advanced tools
Comparing version
@@ -10,2 +10,3 @@ import { Module } from '@nuxt/types'; | ||
webpackOptimisations: boolean; | ||
postcssNoPolyfills: boolean; | ||
} | ||
@@ -12,0 +13,0 @@ interface ModuleOptions { |
@@ -2136,3 +2136,9 @@ 'use strict'; | ||
nuxtOptions.build.hardSource = true; | ||
nuxtOptions.build.parallel = true; | ||
const os = require("os"); | ||
const cpuCount = os.cpus().length; | ||
if (cpuCount > 1) { | ||
nuxtOptions.build.parallel = true; | ||
} else { | ||
console.info("Not enabling parallel loader due to limited CPU capacity."); | ||
} | ||
} | ||
@@ -2143,2 +2149,5 @@ if (env.isDev) { | ||
nuxtOptions.build.html.minify = false; | ||
if (options.features.postcssNoPolyfills && options.profile !== "safe" && nuxtOptions.build.postcss && nuxtOptions.build.postcss.preset) { | ||
nuxtOptions.build.postcss.preset.stage = false; | ||
} | ||
} | ||
@@ -2242,2 +2251,5 @@ if (options.profile !== "safe") { | ||
maybeEnableSpeedMeasurePlugin(buildOptimisations, nuxt); | ||
if (buildOptimisations.profile === false) { | ||
return; | ||
} | ||
nuxtOptimiser({options: buildOptimisations, nuxtOptions: nuxt.options, env: {isDev: nuxt.dev}}); | ||
@@ -2244,0 +2256,0 @@ this.extendBuild((config, env) => { |
{ | ||
"name": "nuxt-build-optimisations", | ||
"version": "1.0.0-10", | ||
"version": "1.0.0-11", | ||
"description": "Automatic optimisations for Nuxt build time.", | ||
@@ -22,2 +22,3 @@ "repository": "loonpwn/nuxt-build-optimisations", | ||
"dev:basic": "nuxt-ts test/fixtures/basic", | ||
"dev:bootstrap": "nuxt test/fixtures/bootstrap", | ||
"dev:preset": "nuxt test/fixtures/preset", | ||
@@ -54,2 +55,3 @@ "dev:static": "nuxt-ts test/fixtures/static", | ||
"@nuxtjs/pwa": "^3.3.5", | ||
"@nuxtjs/sitemap": "^2.4.0", | ||
"@nuxtjs/svg": "^0.1.12", | ||
@@ -63,2 +65,3 @@ "@nuxtjs/tailwindcss": "^3.4.2", | ||
"@types/speed-measure-webpack-plugin": "^1.3.1", | ||
"bootstrap-vue": "^2.21.2", | ||
"cheerio": "^1.0.0-rc.5", | ||
@@ -65,0 +68,0 @@ "dotenv-cli": "^4.0.0", |
@@ -15,5 +15,5 @@  | ||
Nuxt is fast but is limited by its webpack build, when your app grows things slow down. | ||
Nuxt.js is fast but is limited by its webpack build, when your app grows things slow down. | ||
Nuxt build optimisations abstracts the complexities of optimising your Nuxt app so anyone can instantly speed up their builds | ||
Nuxt build optimisations abstracts the complexities of optimising your Nuxt.js app so anyone can instantly speed up their builds | ||
without having to learn webpack. | ||
@@ -38,5 +38,7 @@ | ||
**Experimental** | ||
- Development: Disables [postcss-preset-env](https://github.com/csstools/postcss-preset-env) pollyfills | ||
- Replaces [Terser](https://github.com/terser/terser) minification with [esbuild](https://esbuild.github.io/) | ||
- Enable [Nuxt build cache](https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-build#cache) | ||
- webpack's [best practices for performance](https://webpack.js.org/guides/build-performance/) | ||
- Disables Nuxt features that aren't used (layouts, store) | ||
@@ -56,6 +58,6 @@ **Risky** | ||
:warning: This package is in pre-release. Make sure you test your app before deploying this into production. | ||
- :warning: This package makes optimisations with the assumption you're developing on the latest chrome. | ||
- :warning: Make sure you test your app before deploying it production with this package. | ||
- _Note: Nuxt 3 will use Vite which will most likely make this package redundant in the future._ | ||
_Note: Nuxt 3 will use Vite which will most likely make this package redundant in the future._ | ||
--- | ||
@@ -142,7 +144,13 @@ | ||
*Default:* | ||
```shell | ||
esbuildLoader: true, | ||
esbuildMinifier: true, | ||
imageFileLoader: true, | ||
```js | ||
// uses esbuild loader | ||
esbuildLoader: true | ||
// uses esbuild as a minifier | ||
esbuildMinifier: true | ||
// swaps url-loader for file-loader | ||
imageFileLoader: true | ||
// misc webpack optimisations | ||
webpackOptimisations: true | ||
// no polyfilling css in development | ||
postcssNoPolyfills: true | ||
``` | ||
@@ -149,0 +157,0 @@ |
65971
1.61%1961
0.67%198
4.21%31
6.9%