Skip to content

Commit

Permalink
docs(README): update filename formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Aug 8, 2018
1 parent d6931da commit 313c3c4
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ npm i -D postcss-loader

### `Configuration`

**postcss.config.js**
**`postcss.config.js`**
```js
module.exports = {
parser: 'sugarss',
Expand Down Expand Up @@ -72,7 +72,7 @@ Config lookup starts from `path.dirname(file)` and walks the file tree upwards u

After setting up your `postcss.config.js`, add `postcss-loader` to your `webpack.config.js`. You can use it standalone or in conjunction with `css-loader` (recommended). Use it **after** `css-loader` and `style-loader`, but **before** other preprocessor loaders like e.g `sass|less|stylus-loader`, if you use any.

**webpack.config.js**
**`webpack.config.js`**
```js
module.exports = {
module: {
Expand All @@ -88,7 +88,7 @@ module.exports = {

> ⚠️ When `postcss-loader` is used standalone (without `css-loader`) don't use `@import` in your CSS, since this can lead to quite bloated bundles
**webpack.config.js (recommended)**
**`webpack.config.js` (recommended)**
```js
module.exports = {
module: {
Expand Down Expand Up @@ -122,6 +122,7 @@ module.exports = {

If you use JS styles without the [`postcss-js`][postcss-js] parser, add the `exec` option.

**`webpack.config.js`**
```js
{
test: /\.style.js$/,
Expand All @@ -148,7 +149,7 @@ You can manually specify the path to search for your config (`postcss.config.js`
> ⚠️ Note that you **can't** use a **filename** other than the [supported config formats] (e.g `.postcssrc.js`, `postcss.config.js`), this option only allows you to manually specify the **directory** where config lookup should **start** from
**webpack.config.js**
**`webpack.config.js`**
```js
{
loader: 'postcss-loader',
Expand All @@ -173,7 +174,7 @@ You can manually specify the path to search for your config (`postcss.config.js`

`postcss-loader` exposes context `ctx` to the config file, making your `postcss.config.js` dynamic, so can use it to do some real magic ✨

**postcss.config.js**
**`postcss.config.js`**
```js
module.exports = ({ file, options, env }) => ({
parser: file.extname === '.sss' ? 'sugarss' : false,
Expand All @@ -185,7 +186,7 @@ module.exports = ({ file, options, env }) => ({
})
```

**webpack.config.js**
**`webpack.config.js`**
```js
{
loader: 'postcss-loader',
Expand All @@ -202,7 +203,7 @@ module.exports = ({ file, options, env }) => ({

### `Plugins`

**webpack.config.js**
**`webpack.config.js`**
```js
{
loader: 'postcss-loader',
Expand All @@ -229,7 +230,7 @@ module.exports = ({ file, options, env }) => ({

#### `Parser`

**webpack.config.js**
**`webpack.config.js`**
```js
{
test: /\.sss$/,
Expand All @@ -242,7 +243,7 @@ module.exports = ({ file, options, env }) => ({

#### `Syntax`

**webpack.config.js**
**`webpack.config.js`**
```js
{
test: /\.css$/,
Expand All @@ -255,7 +256,7 @@ module.exports = ({ file, options, env }) => ({

#### `Stringifier`

**webpack.config.js**
**`webpack.config.js`**
```js
{
test: /\.css$/,
Expand All @@ -270,7 +271,7 @@ module.exports = ({ file, options, env }) => ({

Enables source map support, `postcss-loader` will use the previous source map given by other loaders and update it accordingly, if no previous loader is applied before `postcss-loader`, the loader will generate a source map for you.

**webpack.config.js**
**`webpack.config.js`**
```js
{
test: /\.css/,
Expand All @@ -288,7 +289,7 @@ Enables source map support, `postcss-loader` will use the previous source map gi
You can set the `sourceMap: 'inline'` option to inline the source map
within the CSS directly as an annotation comment.

**webpack.config.js**
**`webpack.config.js`**
```js
{
loader: 'postcss-loader',
Expand All @@ -308,7 +309,7 @@ within the CSS directly as an annotation comment.

### `Stylelint`

**webpack.config.js**
**`webpack.config.js`**
```js
{
test: /\.css$/,
Expand All @@ -330,9 +331,9 @@ within the CSS directly as an annotation comment.
}
```

### Autoprefixing
### `Autoprefixing`

**webpack.config.js**
**`webpack.config.js`**
```js
{
test: /\.css$/,
Expand Down Expand Up @@ -361,7 +362,7 @@ This loader [cannot be used] with [CSS Modules] out of the box due
to the way `css-loader` processes file imports. To make them work properly,
either add the css-loader’s [`importLoaders`] option.

**webpack.config.js**
**`webpack.config.js`**
```js
{
test: /\.css$/,
Expand All @@ -386,6 +387,7 @@ If you want to process styles written in JavaScript, use the [postcss-js] parser

[postcss-js]: https://github.com/postcss/postcss-js

**`webpack.config.js`**
```js
{
test: /\.style.js$/,
Expand Down Expand Up @@ -425,10 +427,11 @@ export default {

[ExtractPlugin]: https://github.com/webpack-contrib/mini-css-extract-plugin

**webpack.config.js**
**`webpack.config.js`**
```js
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const devMode = process.env.NODE_ENV !== 'production';
const devMode = process.env.NODE_ENV !== 'production'

const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = {
module: {
Expand All @@ -438,14 +441,14 @@ module.exports = {
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'postcss-loader'
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: devMode ? '[name].css' : '[name].[hash].css',
filename: devMode ? '[name].css' : '[name].[hash].css'
})
]
}
Expand Down

0 comments on commit 313c3c4

Please sign in to comment.