Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
refactor(schema,webpack)!: split out webpack and postcss build options (
Browse files Browse the repository at this point in the history
#2812)

* refactor: split out webpack and postcss build options

* feat(schema): set nuxt3 builder in config

* fix(schema): default postcss config file to false

* chore: update lockfile

* style: remove unused imports

* refactor(webpack): remove (previously disabled) babel config

* refactor: move shared vite options into schema

* fix(schema): omit __NUXT_BASE__ from defaults

* fix: move appDir-dependent options back to vite

* refactor: split out virtual modules

* refactor: extract compile/createDevMiddleware

* refactor: further improvements

* chore: remove `@nuxt/webpack-builder` dependency

* chore: update lockfile

* refactor: move `builder` option to top level

* fix: bind close to watcher instance

* chore: update lockfile

* fix: create portal between postcss & build.postcss.postcssOptions

* fix: remove duplicate

* fix: revert

* fix: use `postcss` directly

* fix: import builder from rootDir

* chore: dedupe webpack install

* test: update fixture to use `builder`

* fix: bind class in pify

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
  • Loading branch information
danielroe and pi0 authored Feb 25, 2022
1 parent 2b3dbed commit 73ba30f
Show file tree
Hide file tree
Showing 38 changed files with 1,320 additions and 1,533 deletions.
4 changes: 4 additions & 0 deletions packages/kit/src/module/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export function useModuleContainer (nuxt: Nuxt = useNuxt()): ModuleContainer {
extendBuild (fn) {
// @ts-ignore
nuxt.options.build.extend = chainFn(nuxt.options.build.extend, fn)

if (!isNuxt2(nuxt)) {
console.warn('[kit] [compat] Using `extendBuild` in Nuxt 3 has no effect. Instead call extendWebpackConfig and extendViteConfig.')
}
},

extendRoutes (fn) {
Expand Down
1 change: 0 additions & 1 deletion packages/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@nuxt/nitro": "3.0.0",
"@nuxt/schema": "3.0.0",
"@nuxt/vite-builder": "3.0.0",
"@nuxt/webpack-builder": "3.0.0",
"@vue/reactivity": "^3.2.31",
"@vue/shared": "^3.2.31",
"@vueuse/head": "^0.7.5",
Expand Down
6 changes: 4 additions & 2 deletions packages/nuxt3/src/core/builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import chokidar from 'chokidar'
import type { Nuxt } from '@nuxt/schema'
import { tryImportModule } from '@nuxt/kit'
import { createApp, generateApp } from './app'

export async function build (nuxt: Nuxt) {
Expand Down Expand Up @@ -48,8 +49,9 @@ function watch (nuxt: Nuxt) {
}

async function bundle (nuxt: Nuxt) {
const useVite = nuxt.options.vite !== false
const { bundle } = await (useVite ? import('@nuxt/vite-builder') : import('@nuxt/webpack-builder'))
const { bundle } = typeof nuxt.options.builder === 'string'
? await tryImportModule(nuxt.options.builder, { paths: nuxt.options.rootDir })
: nuxt.options.builder
try {
return bundle(nuxt)
} catch (error) {
Expand Down
11 changes: 10 additions & 1 deletion packages/schema/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export default defineBuildConfig({
name: 'config',
builder: 'untyped',
defaults: {
rootDir: '/<rootDir>/'
rootDir: '/<rootDir>/',
vite: {
base: '/'
}
}
},
'src/index'
Expand All @@ -24,6 +27,12 @@ export default defineBuildConfig({
'webpack-bundle-analyzer',
'rollup-plugin-visualizer',
'vite',
'mini-css-extract-plugin',
'terser-webpack-plugin',
'css-minimizer-webpack-plugin',
'webpack-dev-middleware',
'webpack-hot-middleware',
'postcss',
'consola',
// Implicit
'@vue/compiler-core',
Expand Down
1 change: 1 addition & 0 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"defu": "^5.0.1",
"jiti": "^1.13.0",
"pathe": "^0.2.0",
"postcss-import-resolver": "^2.0.0",
"scule": "^0.2.1",
"std-env": "^3.0.1",
"ufo": "^0.7.9"
Expand Down
Loading

0 comments on commit 73ba30f

Please sign in to comment.