Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace TailwindCSS with Protocol and SCSS for styling #312

Merged
merged 11 commits into from
Jan 13, 2021
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: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
public/build/bundle.js
scripts/build-glean-metadata.js
src/ga.js
src/Tailwindcss.svelte
storybook-static/*
venv/*
9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,19 @@ module.exports = {
"import/no-duplicates": "off",
"import/no-mutable-exports": "off",
"import/no-unresolved": "off",

// Temporarily work around a bug in eslint-plugin-svelte3.
//
// https://github.com/sveltejs/eslint-plugin-svelte3/issues/41#issuecomment-572503966
"no-multiple-empty-lines": ["error", { max: 2, maxBOF: 2, maxEOF: 0 }],
},

// Eslint only allows regular CSS inside <style>, so we
// use this setting to ignore warnings about SCSS/LESS syntax
//
// https://github.com/sveltejs/eslint-plugin-svelte3#svelte3ignore-styles
settings: {
"svelte3/ignore-styles": () => true,
Iinh marked this conversation as resolved.
Show resolved Hide resolved
},
},
{
files: ["tests/**/*.test.js"],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/node_modules/
/public/build/
/public/img/
/public/fonts/
/storybook-static/
venv
*.pyc
Expand Down
33 changes: 32 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const sveltePreprocess = require("svelte-preprocess");
const autoPrefixer = require("autoprefixer");
const path = require("path");

module.exports = {
stories: ["../stories/**/*.stories.js"],
Expand All @@ -10,9 +12,38 @@ module.exports = {
);
svelteLoader.options = {
...svelteLoader.options,
preprocess: sveltePreprocess({ postcss: true }),
preprocess: sveltePreprocess({
postcss: true,
defaults: {
style: "scss",
},
scss: {
prependData: `@import '@mozilla-protocol/core/protocol/css/protocol.scss';`,
},
postcss: {
plugins: [autoPrefixer],
},
}),

// turn off warning about unused CSS selectors to
// shorten Netlify build time. More context:
// https://github.com/mozilla/glean-dictionary/pull/312#issuecomment-759251341

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;
},
};
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import "./story.css";
import "!style-loader!css-loader!sass-loader!../node_modules/@mozilla-protocol/core/protocol/css/protocol.scss";
Iinh marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion .storybook/story.css
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
@import "../src/main.css";
11 changes: 8 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
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",
"/storybook-static/",
],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
"\\.(css|less|scss)$": "<rootDir>/__mocks__/styleMock.js",
},
};
Loading