diff --git a/src/index.js b/src/index.js index 8e1d25ce..b77c9c50 100644 --- a/src/index.js +++ b/src/index.js @@ -157,6 +157,7 @@ export default async function loader(content, map, meta) { try { result = await postcss(plugins).process(content, { + hideNothingWarning: true, from: resourcePath, to: resourcePath, map: options.sourceMap diff --git a/test/loader.test.js b/test/loader.test.js index 0195d0ce..9eb33ee2 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -449,4 +449,28 @@ describe('loader', () => { expect(getWarnings(stats)).toMatchSnapshot('warnings'); expect(getErrors(stats)).toMatchSnapshot('errors'); }); + + // TODO unskip after updating postcss to 8 version + it.skip('should not generate console.warn when plugins disabled and hideNothingWarning is "true"', async () => { + jest.spyOn(console, 'warn').mockImplementation(() => {}); + + const compiler = getCompiler('./empty.js', { + import: false, + url: false, + }); + const stats = await compile(compiler); + + // eslint-disable-next-line no-console + expect(console.warn).not.toHaveBeenCalledWith( + 'You did not set any plugins, parser, or stringifier. ' + + 'Right now, PostCSS does nothing. Pick plugins for your case ' + + 'on https://www.postcss.parts/ and use them in postcss.config.js.' + ); + expect(getModuleSource('./empty.css', stats)).toMatchSnapshot('module'); + expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( + 'result' + ); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); });