Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});