Skip to content

Commit

Permalink
fix(vite): remove postcss-url and duplicate postcss-import (#23861)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored and manniL committed Dec 11, 2023
1 parent ef0b1ad commit d785512
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 37 deletions.
1 change: 0 additions & 1 deletion packages/schema/package.json
Expand Up @@ -60,7 +60,6 @@
"hookable": "^5.5.3",
"pathe": "^1.1.1",
"pkg-types": "^1.0.3",
"postcss-import-resolver": "^2.0.0",
"std-env": "^3.4.3",
"ufo": "^1.3.1",
"unimport": "^3.4.0",
Expand Down
25 changes: 0 additions & 25 deletions packages/schema/src/config/postcss.ts
@@ -1,5 +1,3 @@
import { defu } from 'defu'
import createResolver from 'postcss-import-resolver'
import { defineUntypedSchema } from 'untyped'

export default defineUntypedSchema({
Expand All @@ -11,29 +9,6 @@ export default defineUntypedSchema({
* @type {Record<string, any>}
*/
plugins: {
/**
* https://github.com/postcss/postcss-import
*/
'postcss-import': {
$resolve: async (val, get) => val !== false
? defu(val || {}, {
resolve: createResolver({
alias: { ...(await get('alias')) },
modules: [
await get('srcDir'),
await get('rootDir'),
...(await get('modulesDir'))
]
})
})
: val
},

/**
* https://github.com/postcss/postcss-url
*/
'postcss-url': {},

/**
* https://github.com/postcss/autoprefixer
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/vite/package.json
Expand Up @@ -51,8 +51,6 @@
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.0.3",
"postcss": "^8.4.31",
"postcss-import": "^15.1.0",
"postcss-url": "^10.1.3",
"rollup-plugin-visualizer": "^5.9.2",
"std-env": "^3.4.3",
"strip-literal": "^1.3.0",
Expand Down
1 change: 1 addition & 0 deletions packages/webpack/package.json
Expand Up @@ -45,6 +45,7 @@
"pify": "^6.1.0",
"postcss": "^8.4.31",
"postcss-import": "^15.1.0",
"postcss-import-resolver": "^2.0.0",
"postcss-loader": "^7.3.3",
"postcss-url": "^10.1.3",
"pug-plain-loader": "^1.1.0",
Expand Down
17 changes: 17 additions & 0 deletions packages/webpack/src/utils/postcss.ts
@@ -1,3 +1,4 @@
import createResolver from 'postcss-import-resolver'
import { createCommonJS } from 'mlly'
import { requireModule } from '@nuxt/kit'
import type { Nuxt } from '@nuxt/schema'
Expand Down Expand Up @@ -39,6 +40,22 @@ export const getPostcssConfig = (nuxt: Nuxt) => {
}

const postcssOptions = defu({}, nuxt.options.postcss, {
plugins: {
/**
* https://github.com/postcss/postcss-import
*/
'postcss-import': {
resolve: createResolver({
alias: { ...nuxt.options.alias },
modules: nuxt.options.modulesDir
})
},

/**
* https://github.com/postcss/postcss-url
*/
'postcss-url': {}
},
sourceMap: nuxt.options.webpack.cssSourceMap,
// Array, String or Function
order: 'autoprefixerAndCssnanoLast'
Expand Down
12 changes: 3 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d785512

Please sign in to comment.