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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an example of how you can include a global stylesheet in a next.js webapp.
4
+
5
+
6
+
## How to use
7
+
8
+
Download the example [or clone the repo](https://github.com/zeit/next.js):
9
+
10
+
```bash
11
+
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-global-stylesheet
12
+
cd with-global-stylesheet
13
+
```
14
+
15
+
To get this example running you just need to
16
+
17
+
npm install .
18
+
npm run dev
19
+
20
+
Visit [http://localhost:300](http://localhost:300) and try to modify `pages/style.scss` changing color. Your changes should be picked up instantly.
21
+
22
+
Also see it working with plain css here
23
+

24
+
25
+
Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))
26
+
27
+
```bash
28
+
now
29
+
```
30
+
31
+
32
+
## The idea behind the example
33
+
34
+
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](https://github.com/davibe/babel-plugin-wrap-in-js)
35
+
36
+
This project shows how you can set it up. Have a look at
37
+
- .babelrc
38
+
- next.config.js
39
+
- pages/style.scss
40
+
- pages/index.js
41
+
42
+
43
+
Please, report any issue on enhancement related to this example to its original
0 commit comments