Skip to content

Commit

Permalink
update build docs for PostCSS configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Dec 30, 2020
1 parent 147a6d7 commit 61bd2e0
Showing 1 changed file with 55 additions and 7 deletions.
62 changes: 55 additions & 7 deletions www/pages/docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,61 @@ index: 4
linkheadings: 3
---

# Build Configurations
> [_**Coming Soon!**_](https://github.com/ProjectEvergreen/greenwood/issues/426)
## Build Configurations
> [_**More coming Soon!**_](https://github.com/ProjectEvergreen/greenwood/issues/426)
**Greenwood** offers the ability to extend some of the internal tooling used to better customize the project for those with more advanced use cases than those offered by Greenwood's default. Greenwood is farily unopinionated in its defaults and aims to provide support for modern web standards that are >= Stage 3 (where applicable).

> _For markdown specific options, please see our docs section on [markdown](/docs/markdown/)._
### PostCSS

To provide addition configurations and optimizations around CSS, user's can add a _postcss.config.js_ file within a project's root directory to take advantage of [**PostCSS**](https://postcss.org/).

For example, if you wanted to write CSS with nested selectors, you would want do the following:

1. Install the relevant PostCSS plugin
```shell
$ npm install postcss-nested --save-dev
```
1. Create a _postcss.config.js_ file and `require` your plugin
```js
module.exports = {
plugins: [
require('postcss-nested')
]
};
```
1. Now you can write nested CSS!
```css
:host {
& .card {
padding: 2.5rem;
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: initial;
text-align: center;
& .body {
padding:10px;
}
@media(max-width:768px) {
padding:0;
}
}
}
```

> _For reference, [this is the default _postcss.config.js_](https://github.com/ProjectEvergreen/greenwood/blob/master/packages/cli/src/config/postcss.config.js) being provided by Greenwood._

<!--
> Note: [.browserslistrc](#browserslist) is used by postcss and is also needed to be overwritten. You can override that in that same directory or you may also configure postcss-preset-env to use default `.browserslistrc` path via environement variable to: `./node_modules/@greenwood/cli/src/config/.browserslistrc`. See [postcss-preset-env docs](https://www.npmjs.com/package/postcss-preset-env#browsers) for further information. [Ejecting configuration](#eject-configuration) is one way in which you can easily override both with no extra configuraiton.
-->

<!--
A number of [core build configuration files](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/cli/src/config) can be overridden by creating each file within the root path of your project. You can also automate this task in a single command [see eject configurations](#eject-configurations).
Expand Down Expand Up @@ -36,11 +89,6 @@ By default, [this is the postcss.config.js](https://github.com/ProjectEvergreen/

> Note: [.browserslistrc](#browserslist) is used by postcss and is also needed to be overwritten. You can override that in that same directory or you may also configure postcss-preset-env to use default `.browserslistrc` path via environement variable to: `./node_modules/@greenwood/cli/src/config/.browserslistrc`. See [postcss-preset-env docs](https://www.npmjs.com/package/postcss-preset-env#browsers) for further information. [Ejecting configuration](#eject-configuration) is one way in which you can easily override both with no extra configuraiton.

### Webpack
The webpack config for production(`webpack.config.prod.js`) and development(`webpack.config.develop.js`) can be overridden by providing your own custom configuration within your project's directory. You can eject the default core configurations into your project using greenwood cli [eject](#eject-configurations) command and then edit them after, which is the simplest and recommended method for modifying webpack config. If you wish to revert back to the default provided configuration, simply delete these 2 files from your project's root directory.
A number of core build configuration files can be overridden by creating each file within the root path of your project.
### Eject Configurations

From greenwood CLI you can eject [core configuration files(webpack, postcss, babel, browserslistrc)](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/cli/src/config) into your project's working directory which will make it easier to add your own customizations. To do so, add the following to your package.json `scripts` object:
Expand Down

0 comments on commit 61bd2e0

Please sign in to comment.