Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

Research CSS Solutions #3

Closed
francium opened this issue Nov 10, 2018 · 4 comments
Closed

Research CSS Solutions #3

francium opened this issue Nov 10, 2018 · 4 comments
Assignees

Comments

@francium
Copy link
Contributor

Look at how SPA (single page applications) and frameworks like React and VueJS handle CSS.

Is it possible to use some library that provides inline CSS via JavaScript?

@francium francium assigned PrinceSxndhu and BJToor and unassigned PrinceSxndhu Nov 10, 2018
@francium
Copy link
Contributor Author

@francium
Copy link
Contributor Author

@francium
Copy link
Contributor Author

francium commented Dec 1, 2018

CSS Modules and SCSS can be setup with parcel by using PostCSS and PoctCSS Modules.
You will need to install the postcss-modules module and configure using .postcssrc in the root of the project,

{
    "modules": true,
    "plugins": {
        "postcss-modules": {
            "generateScopedName": "[name]_[local]_[hash:base64:5]"
        }
    }
}

Do note, in the previous snippet, only the "modules": true is strictly required as per
maintainer(1), but this alone results in styles breaking when a hot reload occurs. The
"plugins" section fixes this issue(2).

At the time of writing, this setup allowed SCSS support, hot reloading styles, importing
into JavaScript using ES6 syntax, import styles from './foo.scss', and CSS
modularization (CSS Modules)

(1): parcel-bundler/parcel#70
(2): [Bug] HMR and PostCSS modules, styles disappear, parcel-bundler/parcel#809

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

No branches or pull requests

3 participants