Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
0d0ab77d
Commit
0d0ab77d
authored
May 27, 2017
by
Thomas Lindstrøm
Committed by
Tim Neutkens
May 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update example `with-scoped-stylesheets-and-postcss` (#1606)
Fixes #1191
parent
787a110b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
56 deletions
+28
-56
.babelrc
examples/with-scoped-stylesheets-and-postcss/.babelrc
+0
-10
README.md
examples/with-scoped-stylesheets-and-postcss/README.md
+2
-22
next.config.js
examples/with-scoped-stylesheets-and-postcss/next.config.js
+12
-16
package.json
examples/with-scoped-stylesheets-and-postcss/package.json
+5
-6
global.css
...ples/with-scoped-stylesheets-and-postcss/pages/global.css
+3
-0
styles.css
...ples/with-scoped-stylesheets-and-postcss/pages/styles.css
+1
-1
postcss.config.js
...les/with-scoped-stylesheets-and-postcss/postcss.config.js
+5
-1
No files found.
examples/with-scoped-stylesheets-and-postcss/.babelrc
deleted
100644 → 0
View file @
787a110b
{
"presets": [
"next/babel"
],
"plugins": [
["wrap-in-js", {
"extensions": ["css$"]
}]
]
}
examples/with-scoped-stylesheets-and-postcss/README.md
View file @
0d0ab77d
...
...
@@ -29,26 +29,6 @@ now
Scoped CSS is neat and keeps your JS clean. PostCSS is amazing for extended features, such as nesting. CSS Modules keep your class names “local”.
# Known
bug
s
# Known
issue
s
There's a bug, possibly within
`next.js`
, making composition between files unuseable. Consider the following:
*`styles.css`*
```
css
.paragraph
{
composes
:
font-sans
from
'../global.css'
;
}
```
*`global.css`*
```
css
.font-sans
{
font-family
:
georgia
;
/* ;) */
}
```
The following error is thrown:
```
Module build failed: Error: Cannot find module '-!./../node_modules/css-loader/index.js??ref--6-4!./../node_modules/postcss-loader/index.js!../global.css'
```
Composed CSS files are not watched by next.js, and thus, if you change one, nothing will happen. You'll need to edit a JS file or the CSS file you're composing for it to hot reload.
examples/with-scoped-stylesheets-and-postcss/next.config.js
View file @
0d0ab77d
const
trash
=
require
(
'trash'
)
module
.
exports
=
{
webpack
:
(
config
)
=>
{
config
.
module
.
rules
.
push
(
...
...
@@ -10,27 +12,21 @@ module.exports = {
name
:
'dist/[path][name].[ext]'
}
},
'raw-loader'
,
'val-loader'
,
{
loader
:
'skeleton-loader'
,
options
:
{
procedure
:
(
content
)
=>
(
`
${
content
}
\n`
+
[
'module.exports = {'
,
'stylesheet: module.exports.toString(),'
,
'classNames: exports.locals'
,
procedure
:
function
(
content
)
{
const
fileName
=
`
${
this
.
_module
.
userRequest
}
.json`
const
classNames
=
JSON
.
stringify
(
require
(
fileName
))
trash
(
fileName
)
return
[
'module.exports = {'
,
`classNames:
${
classNames
}
,`
,
`stylesheet: \`
${
content
}
\``
,
'}'
].
join
(
''
)
)
}
},
{
loader
:
'css-loader'
,
options
:
{
modules
:
true
,
minimize
:
true
,
importLoaders
:
1
,
localIdentName
:
'[local]-[hash:base64:5]'
}
}
},
'postcss-loader'
...
...
examples/with-scoped-stylesheets-and-postcss/package.json
View file @
0d0ab77d
...
...
@@ -10,18 +10,17 @@
"author"
:
"Thomas Lindstrøm <t@hom.as>"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"babel-plugin-wrap-in-js"
:
"^1.1.1"
,
"css-loader"
:
"^0.26.1"
,
"cssnano"
:
"^3.10.0"
,
"next"
:
"latest"
,
"postcss-cssnext"
:
"^2.9.0"
,
"postcss-loader"
:
"^1.3.0"
,
"
raw-loader"
:
"^0.5.1
"
,
"
postcss-modules"
:
"^0.6.4
"
,
"react"
:
"^15.4.2"
,
"react-dom"
:
"^15.4.2"
,
"skeleton-loader"
:
"
0.0.7
"
,
"
val-loader"
:
"^0.5.0
"
"skeleton-loader"
:
"
^1.1.2
"
,
"
trash"
:
"^4.0.1
"
},
"devDependencies"
:
{
"now"
:
"^
3.1.0
"
"now"
:
"^
4.10.3
"
}
}
examples/with-scoped-stylesheets-and-postcss/pages/global.css
0 → 100644
View file @
0d0ab77d
.font-color
{
color
:
blue
;
}
examples/with-scoped-stylesheets-and-postcss/pages/styles.css
View file @
0d0ab77d
.paragraph
{
composes
:
font-color
from
'./global.css'
;
font-size
:
20px
;
color
:
red
;
}
examples/with-scoped-stylesheets-and-postcss/postcss.config.js
View file @
0d0ab77d
module
.
exports
=
{
plugins
:
[
require
(
'postcss-cssnext'
)()
require
(
'postcss-cssnext'
)(),
require
(
'postcss-modules'
)({
generateScopedName
:
'[local]-[hash:base64:5]'
}),
require
(
'cssnano'
)()
]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment