Skip to content

Commit

Permalink
Merge pull request #9 from yuri-scarbaci-lenio/feature/allow-custom-m…
Browse files Browse the repository at this point in the history
…iniCssExtractOptions

address Issue #7
  • Loading branch information
webdeb authored Mar 13, 2020
2 parents b26255c + f415e8a commit f2c642a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 65 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# version 1.0.7

## Changes:
- can now specify miniCssExtractOptions configuration inside next.config.js
- updated outdated dependencies and fixed `npm audit` warnings for `acorn`, `kind-of` and `node-sass`
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ module.exports = withStyles({
},
},
cssLoaderOptions: {...},
postcssLoaderOptions: {...}
postcssLoaderOptions: {...},
miniCssExtractOptions: {...} // ignoreOrder:true for https://github.com/webpack-contrib/mini-css-extract-plugin/issues/250#issuecomment-544898772
})
```

Expand All @@ -55,6 +56,18 @@ export default function MyApp({ Component, pageProps }) {
}
```

## How to contribute

1. fork the project `~master`
1. locally clone the project in your machine ( `git clone https/ssh github link to your fork` )
1. create a new branch in your fork ( `git checkout -b your/branch/name` )
1. run `npm install` in your local clone of the repo
1. apply your code changes ( keep `CHANGELOG.md` and the `README.md` file up to date, also modify `package.json` `version` as fit!)
1. run `npm pack` in your local clone of the repo
1. test your changes against a next.js project that uses your local repo ( use `npm install --save path/to/local/repo/{version}.tgz` to test your locally changed code)
1. if your code work as expected, remove the packed tgz file from the repo and commit to your fork
1. create a PR to apply your fork in this repository

## Credits

Most of the code was taken from the official `next-css` & `next-sass` package.
108 changes: 49 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webdeb/next-styles",
"version": "1.0.5",
"version": "1.0.7",
"description": "CSS / SASS / CssModules in Next.js",
"main": "index.js",
"scripts": {
Expand All @@ -18,12 +18,12 @@
"author": "Boris Kotov <[email protected]> (http://www.webdeb.de/)",
"license": "MIT",
"dependencies": {
"extracted-loader": "^1.0.7",
"css-loader": "^3.4.0",
"extracted-loader": "^1.0.7",
"find-up": "^4.1.0",
"ignore-loader": "~0.1.2",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.13.0",
"node-sass": "^4.13.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss-loader": "^3.0.0",
"sass-loader": "^8.0.0"
Expand Down
11 changes: 9 additions & 2 deletions withStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = (nextConfig = {}) => {
sassLoaderOptions,
cssLoaderOptions,
postcssLoaderOptions,
miniCssExtractOptions
} = nextConfig

const issuer = issuer => {
Expand All @@ -33,13 +34,14 @@ module.exports = (nextConfig = {}) => {
typeof modules === "object"
? modules
: !!modules && {
localIdentName: dev ? "[path][name]__[local]" : "[hash:base64:8]",
}
localIdentName: dev ? "[path][name]__[local]" : "[hash:base64:8]",
}

options.defaultLoaders.css = getStyleLoaders(config, {
extensions: ["css"],
cssLoaderOptions,
postcssLoaderOptions,
miniCssExtractOptions,
dev,
isServer,
})
Expand All @@ -56,6 +58,7 @@ module.exports = (nextConfig = {}) => {
cssModules,
cssLoaderOptions,
postcssLoaderOptions,
miniCssExtractOptions,
dev,
isServer,
})
Expand All @@ -77,6 +80,7 @@ module.exports = (nextConfig = {}) => {
loaders: [sassLoader],
cssLoaderOptions,
postcssLoaderOptions,
miniCssExtractOptions,
dev,
isServer,
})
Expand All @@ -95,6 +99,7 @@ module.exports = (nextConfig = {}) => {
cssModules,
cssLoaderOptions,
postcssLoaderOptions,
miniCssExtractOptions,
dev,
isServer,
})
Expand Down Expand Up @@ -126,6 +131,7 @@ const getStyleLoaders = (
extensions = [],
postcssLoaderOptions = {},
cssLoaderOptions,
miniCssExtractOptions,
loaders = [],
}
) => {
Expand Down Expand Up @@ -155,6 +161,7 @@ const getStyleLoaders = (
? "static/chunks/[name].chunk.css"
: "static/chunks/[name].[contenthash:8].chunk.css",
hot: dev,
...miniCssExtractOptions
})
)
extractCssInitialized = true
Expand Down

0 comments on commit f2c642a

Please sign in to comment.