Adding CSS stylesheets

Seb edited this page Jan 30, 2015 · 1 revision

It is recommended to use parcelify as this allows a CSS dependency (as you no it from browserify).

  1. Add your CSS files to the style field

(package.json)

 "style" : "css/*.css"

or

 "style" : "*.scss"

Important: the registry now only picks the style dependencies - it doesn't merge it with your css files in the sniper section. So be sure that you add all css files - the "style" attribute can also be an array.

  1. Adding a build tasks and updating the sniper

2.1) Install parcelify

npm install parcelify --save-dev

2.2) Adding it as a build task

(package.json)

"scripts": {
...
 "css": "parcelify ./ -c build/bundle.css",
...
}

2.3) Update the sniper

css: ["/build/bundle.css"]

2.4) Optional: Parcelify has a watch mode

parcelify ./ -w -c build/bundle.css
  1. Using a preprocessor (SASS, LESS, ...)

-> you need to a parcelify transform

  "transforms" : [ "sass-css-stream" ],
  "dependencies" : {
    "sass-css-stream": "~0.0.1"
  }

learn more

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.