Skip to content

Commit dd52931

Browse files
feat: hide warning on no plugins (#1195)
1 parent 52412f6 commit dd52931

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export default async function loader(content, map, meta) {
157157

158158
try {
159159
result = await postcss(plugins).process(content, {
160+
hideNothingWarning: true,
160161
from: resourcePath,
161162
to: resourcePath,
162163
map: options.sourceMap

test/loader.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -449,4 +449,28 @@ describe('loader', () => {
449449
expect(getWarnings(stats)).toMatchSnapshot('warnings');
450450
expect(getErrors(stats)).toMatchSnapshot('errors');
451451
});
452+
453+
// TODO unskip after updating postcss to 8 version
454+
it.skip('should not generate console.warn when plugins disabled and hideNothingWarning is "true"', async () => {
455+
jest.spyOn(console, 'warn').mockImplementation(() => {});
456+
457+
const compiler = getCompiler('./empty.js', {
458+
import: false,
459+
url: false,
460+
});
461+
const stats = await compile(compiler);
462+
463+
// eslint-disable-next-line no-console
464+
expect(console.warn).not.toHaveBeenCalledWith(
465+
'You did not set any plugins, parser, or stringifier. ' +
466+
'Right now, PostCSS does nothing. Pick plugins for your case ' +
467+
'on https://www.postcss.parts/ and use them in postcss.config.js.'
468+
);
469+
expect(getModuleSource('./empty.css', stats)).toMatchSnapshot('module');
470+
expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot(
471+
'result'
472+
);
473+
expect(getWarnings(stats)).toMatchSnapshot('warnings');
474+
expect(getErrors(stats)).toMatchSnapshot('errors');
475+
});
452476
});

0 commit comments

Comments
 (0)