From 1bd4fb14abf0e6a0e7b86dc20999a76ff913aaa9 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Sat, 30 Mar 2019 20:12:12 +0100 Subject: [PATCH] chore(postcss): deprecate config support (#5419) --- packages/webpack/src/utils/postcss.js | 10 ++++++++ test/fixtures/with-config/with-config.test.js | 24 +++++++------------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/webpack/src/utils/postcss.js b/packages/webpack/src/utils/postcss.js index dfac1c26fd..5b75b1705e 100644 --- a/packages/webpack/src/utils/postcss.js +++ b/packages/webpack/src/utils/postcss.js @@ -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 } } diff --git a/test/fixtures/with-config/with-config.test.js b/test/fixtures/with-config/with-config.test.js index a0ab037806..357d56e1fb 100644 --- a/test/fixtures/with-config/with-config.test.js +++ b/test/fixtures/with-config/with-config.test.js @@ -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)