Skip to content

Commit

Permalink
fix: avoid postcss warning about no plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Anidetrix committed May 1, 2020
1 parent c0995e6 commit dbd72b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/loaders/postcss/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import postcssImport from "./import";
import postcssUrl from "./url";
import postcssModules from "./modules";
import postcssICSS from "./icss";
import postcssNoop from "./noop";

type LoadedConfig = ReturnType<typeof loadPostCSSConfig> extends PromiseLike<infer T> ? T : never;

Expand Down Expand Up @@ -124,6 +125,9 @@ const loader: Loader<PostCSSLoaderOptions> = {
if (!options.extract && options.minimize)
plugins.push(cssnano(typeof options.minimize === "object" ? options.minimize : {}));

// Avoid PostCSS warning
if (plugins.length === 0) plugins.push(postcssNoop);

const res = await postcss(plugins).process(code, postcssOpts);

for (const warning of res.warnings())
Expand Down
9 changes: 9 additions & 0 deletions src/loaders/postcss/noop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import postcss from "postcss";

const name = "styles-noop";

const noop = (): void => {
/* noop */
};

export default postcss.plugin(name, () => noop);

0 comments on commit dbd72b7

Please sign in to comment.