Skip to content

Commit

Permalink
chore(postcss): deprecate config support (#5419)
Browse files Browse the repository at this point in the history
  • Loading branch information
manniL authored and pi0 committed Mar 30, 2019
1 parent 8b99695 commit 1bd4fb1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
10 changes: 10 additions & 0 deletions packages/webpack/src/utils/postcss.js
Expand Up @@ -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
Expand Down Expand Up @@ -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 [
Expand All @@ -81,6 +90,7 @@ export default class PostcssConfig {
]) {
const configFile = path.resolve(dir, file)
if (fs.existsSync(configFile)) {
postcssConfigFileWarning()
return configFile
}
}
Expand Down
24 changes: 8 additions & 16 deletions test/fixtures/with-config/with-config.test.js
Expand Up @@ -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)
Expand Down

0 comments on commit 1bd4fb1

Please sign in to comment.