mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
chore(postcss): deprecate config support (#5419)
This commit is contained in:
parent
8b9969599d
commit
1bd4fb14ab
@ -28,6 +28,14 @@ export const orderPresets = {
|
||||
}
|
||||
}
|
||||
|
||||
function postcssConfigFileWarning() {
|
||||
if (postcssConfigFileWarning.executed) {
|
||||
return
|
||||
}
|
||||
consola.warn('Please use `build.postcss` in your nuxt.config.js instead of an external config file. Support for such files will be removed in Nuxt 3 as they remove all defaults set by Nuxt and can cause severe problems with features like alias resolving inside your CSS.')
|
||||
postcssConfigFileWarning.executed = true
|
||||
}
|
||||
|
||||
export default class PostcssConfig {
|
||||
constructor(buildContext) {
|
||||
this.buildContext = buildContext
|
||||
@ -70,6 +78,7 @@ export default class PostcssConfig {
|
||||
searchConfigFile() {
|
||||
// Search for postCSS config file and use it if exists
|
||||
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||
// TODO: Remove in Nuxt 3
|
||||
const { srcDir, rootDir } = this.buildContext.options
|
||||
for (const dir of [ srcDir, rootDir ]) {
|
||||
for (const file of [
|
||||
@ -81,6 +90,7 @@ export default class PostcssConfig {
|
||||
]) {
|
||||
const configFile = path.resolve(dir, file)
|
||||
if (fs.existsSync(configFile)) {
|
||||
postcssConfigFileWarning()
|
||||
return configFile
|
||||
}
|
||||
}
|
||||
|
24
test/fixtures/with-config/with-config.test.js
vendored
24
test/fixtures/with-config/with-config.test.js
vendored
@ -14,26 +14,18 @@ const hooks = [
|
||||
|
||||
describe('with-config', () => {
|
||||
buildFixture('with-config', () => {
|
||||
expect(consola.warn).toHaveBeenCalledTimes(5)
|
||||
expect(consola.warn).toHaveBeenCalledTimes(6)
|
||||
expect(consola.fatal).toHaveBeenCalledTimes(0)
|
||||
expect(consola.warn.mock.calls).toMatchObject([
|
||||
[
|
||||
'Unknown mode: unknown. Falling back to universal'
|
||||
],
|
||||
[
|
||||
`Invalid plugin mode (server/client/all): 'abc'. Falling back to 'all'`
|
||||
],
|
||||
['Unknown mode: unknown. Falling back to universal'],
|
||||
['Invalid plugin mode (server/client/all): \'abc\'. Falling back to \'all\''],
|
||||
[{
|
||||
message: 'Found 2 plugins that match the configuration, suggest to specify extension:',
|
||||
additional: expect.stringContaining('plugins/test.json')
|
||||
'additional': expect.stringContaining('plugins/test.json'),
|
||||
'message': 'Found 2 plugins that match the configuration, suggest to specify extension:'
|
||||
}],
|
||||
[
|
||||
'Using styleResources without the nuxt-style-resources-module is not suggested and can lead to severe performance issues.',
|
||||
'Please use https://github.com/nuxt-community/style-resources-module'
|
||||
],
|
||||
[
|
||||
'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.'
|
||||
]
|
||||
['Please use `build.postcss` in your nuxt.config.js instead of an external config file. Support for such files will be removed in Nuxt 3 as they remove all defaults set by Nuxt and can cause severe problems with features like alias resolving inside your CSS.'],
|
||||
['Using styleResources without the nuxt-style-resources-module is not suggested and can lead to severe performance issues.', 'Please use https://github.com/nuxt-community/style-resources-module'],
|
||||
['Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.']
|
||||
])
|
||||
expect(customCompressionMiddlewareFunctionName).toBe('damn')
|
||||
}, hooks)
|
||||
|
Loading…
Reference in New Issue
Block a user