chore(postcss): deprecate config support (#5419)

This commit is contained in:
Alexander Lichter 2019-03-30 20:12:12 +01:00 committed by Pooya Parsa
parent 8b9969599d
commit 1bd4fb14ab
2 changed files with 18 additions and 16 deletions

View File

@ -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 { export default class PostcssConfig {
constructor(buildContext) { constructor(buildContext) {
this.buildContext = buildContext this.buildContext = buildContext
@ -70,6 +78,7 @@ export default class PostcssConfig {
searchConfigFile() { searchConfigFile() {
// Search for postCSS config file and use it if exists // Search for postCSS config file and use it if exists
// https://github.com/michael-ciniawsky/postcss-load-config // https://github.com/michael-ciniawsky/postcss-load-config
// TODO: Remove in Nuxt 3
const { srcDir, rootDir } = this.buildContext.options const { srcDir, rootDir } = this.buildContext.options
for (const dir of [ srcDir, rootDir ]) { for (const dir of [ srcDir, rootDir ]) {
for (const file of [ for (const file of [
@ -81,6 +90,7 @@ export default class PostcssConfig {
]) { ]) {
const configFile = path.resolve(dir, file) const configFile = path.resolve(dir, file)
if (fs.existsSync(configFile)) { if (fs.existsSync(configFile)) {
postcssConfigFileWarning()
return configFile return configFile
} }
} }

View File

@ -14,26 +14,18 @@ const hooks = [
describe('with-config', () => { describe('with-config', () => {
buildFixture('with-config', () => { buildFixture('with-config', () => {
expect(consola.warn).toHaveBeenCalledTimes(5) expect(consola.warn).toHaveBeenCalledTimes(6)
expect(consola.fatal).toHaveBeenCalledTimes(0) expect(consola.fatal).toHaveBeenCalledTimes(0)
expect(consola.warn.mock.calls).toMatchObject([ expect(consola.warn.mock.calls).toMatchObject([
[ ['Unknown mode: unknown. Falling back to universal'],
'Unknown mode: unknown. Falling back to universal' ['Invalid plugin mode (server/client/all): \'abc\'. Falling back to \'all\''],
],
[
`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:'
}], }],
[ ['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.', ['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'],
'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.']
],
[
'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.'
]
]) ])
expect(customCompressionMiddlewareFunctionName).toBe('damn') expect(customCompressionMiddlewareFunctionName).toBe('damn')
}, hooks) }, hooks)