Skip to content

Commit

Permalink
Disable 'unused-css-selector' warning in Storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
Iinh committed Jan 13, 2021
1 parent ac21dad commit 9934c1f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
10 changes: 9 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const sveltePreprocess = require("svelte-preprocess");
const autoPrefixer = require("autoprefixer");
const path = require("path");

module.exports = {
stories: ["../stories/**/*.stories.js"],
Expand All @@ -17,18 +18,25 @@ module.exports = {
style: "scss",
},
scss: {
prependData: `@import 'node_modules/@mozilla-protocol/core/protocol/css/protocol.scss';`,
prependData: `@import '@mozilla-protocol/core/protocol/css/protocol.scss';`,
},
postcss: {
plugins: [autoPrefixer],
},
}),
onwarn: (warning, handler) => {
const { code } = warning;
if (code === "css-unused-selector") return;

handler(warning);
},
};

config.module.rules.push({
// this is for both less and scss
test: /.*\.(?:le|c|sc)ss$/,
loaders: ["style-loader", "css-loader", "sass-loader"],
include: path.resolve(__dirname, "../"),
});

return config;
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = {
transform: {
"^.+\\.svelte$": "svelte-jester",
"^.+\\.svelte$": ["svelte-jester", { preprocess: true }],
"^.+\\.js$": "babel-jest",
},
moduleFileExtensions: ["js", "svelte", "json"],
testPathIgnorePatterns: ["/node_modules/", "/public/", "/storybook-static/"],
testPathIgnorePatterns: ["/node_modules/", "/public/", "/.storybook"],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/__mocks__/fileMock.js",
Expand Down
17 changes: 1 addition & 16 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
const production = !process.env.ROLLUP_WATCH;
module.exports = {
/* eslint-disable global-require */
plugins: [
require("postcss-import"),
require("@fullhuman/postcss-purgecss")({
content: ["index.html", "./src/**/*.svelte", "./src/**/*.html"],
enabled: production,
options: {
/* eslint-disable no-unused-vars */
defaultExtractor: (content) =>
[...content.matchAll(/(?:class:)*([\w\d-/:%.]+)/gm)].map(
([_match, group, ..._rest]) => group
),
},
variables: true,
}),
],
plugins: [require("postcss-import")],
};

0 comments on commit 9934c1f

Please sign in to comment.