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

Better modular css solution #27

Open
ben-pr-p opened this issue Jul 31, 2017 · 2 comments
Open

Better modular css solution #27

ben-pr-p opened this issue Jul 31, 2017 · 2 comments

Comments

@ben-pr-p
Copy link
Contributor

We have brandnewcongress.org, justicedemocrats.com, and soon to be candidatename.com.

We need some system that has some global css, some page specific css (/events, /platform, etc.) – and some brand specific css (color variables, logo positioning, etc.).

@lukewestby, do you know of any good way to approach this type of situation?

At the moment, I have an app.css, which is a bundle of all these css files

    css: [
      './web/static/css/app.css',
      './web/static/css/bnc.css',
      './web/static/css/jd.css',
      './web/static/css/footer.css',
      './web/static/css/header.css',
      './web/static/css/tab-menu.css'
    ]

However, I'm serving both bnc.css and jd.css when it's either bnc or jd, they're just being conditionally applied based on a .bnc or .jd class on the body.

At the moment, I'm also putting page specific styles in inline <style> </style> tags inside the page templates. That works, and it lets me use .eex if statements for my css which is kind of nice, but it leads to unwieldy files.

Does anyone know what typical solutions to this type of architecture are?

@ben-pr-p
Copy link
Contributor Author

We could start using a preprocessor, and we output a different css bundle like:

/static
-- bnc.css
-- jd.css
-- candidate.css

Each has all global styles with colors determined by sass, stylus, or less variables.

I would love to use a preprocessor, but is it possible to hack webpack to take one input css file and output multiple different css files with different values for variables?

@ben-pr-p
Copy link
Contributor Author

Re: page specific css, are the performance improvements to be gained by splitting up the css bundles worth the effort, or should we serve one bundle with css for all routes on the site?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant