1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-global-stylesheet
Fabien Le Frapper 22c22efc35 Fix missing dependencies (#1232)
Tried to pull & run this example, it failed, complaining about missing react & react-dom dependencies
2017-02-21 16:40:18 +01:00
..
pages add global stylesheet example (#1016) 2017-02-12 00:22:35 +01:00
.babelrc add global stylesheet example (#1016) 2017-02-12 00:22:35 +01:00
example.gif add global stylesheet example (#1016) 2017-02-12 00:22:35 +01:00
next.config.js add global stylesheet example (#1016) 2017-02-12 00:22:35 +01:00
package.json Fix missing dependencies (#1232) 2017-02-21 16:40:18 +01:00
README.md add global stylesheet example (#1016) 2017-02-12 00:22:35 +01:00

Global Stylesheet example

This is an example of how you can include a global stylesheet in a next.js webapp.

How to use

Download the example or clone the repo:

curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-global-stylesheet
cd with-global-stylesheet 

To get this example running you just need to

npm install .
npm run dev

Visit http://localhost:300 and try to modify pages/style.scss changing color. Your changes should be picked up instantly.

Also see it working with plain css here example

Deploy it to the cloud with now (download)

now

The idea behind the example

The strategy here is to transpile the stylesheet file to a css-in-js file so that it can be loaded and hot reloaded both on the server and the client. For this purpose i created a babel loader plugin called babel-loader-wrap-in-js

This project shows how you can set it up. Have a look at

  • .babelrc
  • next.config.js
  • pages/style.scss
  • pages/index.js

Please, report any issue on enhancement related to this example to its original github repository https://github.com/davibe/next.js-css-global-style-test