Skip to content

Commit 563856f

Browse files
orlinrauchg
authored andcommitted
postcss-loader, postcss-easy-import, normalize.css and autoprefixer (vercel#1352)
1 parent 5947716 commit 563856f

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

examples/with-global-stylesheet/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ Another babel plugin [module-resolver](https://github.com/tleunen/babel-plugin-m
3737

3838
The `sass-loader` is configured with `includePaths: ['styles', 'node_modules']` so that your scss can `@import` from those places, again without relative paths, for maximum convenience and ability to use npm-published libraries. Furthermore, `glob` paths are also supported, so one could for example add `'node_modules/@material/*'` to the `includePaths`, which would make [material-components-web](https://github.com/material-components/material-components-web) (if you'd like) even easier to work with.
3939

40+
Furthermore, PostCSS is used to [pre-process](https://blog.madewithenvy.com/webpack-2-postcss-cssnext-fdcd2fd7d0bd#.r6t2d0smy) both `css` and `scss` stylesheets, the latter after Sass pre-processing. This is to illustrate `@import 'normalize.css';` from `node_modules` thanks to `postcss-easy-import`. [Autoprefixer](https://github.com/postcss/autoprefixer) is also added as a "best practice". Consider [cssnext](http://cssnext.io) instead, which includes `autoprefixer` as well as many other CSS spec features.
41+
4042
This project shows how you can set it up. Have a look at:
4143
- .babelrc
4244
- next.config.js
4345
- pages/index.js
46+
- postcss.config.js
4447
- styles/index.scss
4548

4649
Please, report any issue on enhancement related to this example to its original

examples/with-global-stylesheet/next.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ module.exports = {
1414
,
1515
{
1616
test: /\.css$/,
17-
use: ['babel-loader', 'raw-loader']
17+
use: ['babel-loader', 'raw-loader', 'postcss-loader']
1818
}
1919
,
2020
{
2121
test: /\.s(a|c)ss$/,
22-
use: ['babel-loader', 'raw-loader',
22+
use: ['babel-loader', 'raw-loader', 'postcss-loader',
2323
{ loader: 'sass-loader',
2424
options: {
2525
includePaths: ['styles', 'node_modules']

examples/with-global-stylesheet/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
"author": "Davide Bertola <dade@dadeb.it>",
1111
"license": "ISC",
1212
"dependencies": {
13+
"autoprefixer": "6.7.6",
1314
"babel-plugin-module-resolver": "2.5.0",
1415
"babel-plugin-wrap-in-js": "^1.1.0",
1516
"glob": "7.1.1",
1617
"next": "^2.0.0-beta.18",
1718
"node-sass": "^4.4.0",
19+
"normalize.css": "5.0.0",
20+
"postcss-easy-import": "2.0.0",
21+
"postcss-loader": "1.3.3",
1822
"raw-loader": "^0.5.1",
1923
"react": "^15.4.2",
2024
"react-dom": "^15.4.2",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: [
3+
require('postcss-easy-import')({prefix: '_'}), // keep this first
4+
require('autoprefixer')({ /* ...options */ }) // so imports are auto-prefixed too
5+
]
6+
}

examples/with-global-stylesheet/styles/index.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import 'normalize.css';
2+
13
p {
24
font-size: xx-large;
35
color: black;

examples/with-global-stylesheet/styles/index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import 'normalize.css';
2+
13
$primary-color: black;
24

35
p {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy