Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add style extension #512

Merged
merged 6 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions content/en/guides/configuration-glossary/configuration-css.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ export default {
```

Nuxt.js will automatically guess the file type by its extension and use the appropriate pre-processor loader for webpack. You will still need to install the required loader if you need to use them.

### Style Extensions

You can omit the file extension for CSS/SCSS/Postcss/Less/Stylus/... files listed in the css array in your nuxt config file.

```js{}[nuxt.config.js]
export default {
css: ['~/assets/css/main', '~/assets/css/animations']
}
```

<base-alert>

If you have two files with the same name eg. main.scss and main.css, and don't add an extension in the css array eg. `css:['~/assets/css/main']`, then the files will be loaded in a specific order, first the css file and then the scss file.
debs-obrien marked this conversation as resolved.
Show resolved Hide resolved

</base-alert>

Default order: `['css', 'pcss', 'postcss', 'styl', 'stylus', 'scss', 'sass', 'less']`
12 changes: 11 additions & 1 deletion content/en/guides/directory-structure/nuxt-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,20 @@ This option lets you define the CSS files, modules, and libraries you want to in

```js{}[nuxt.config.js]
export default {
css: ['~/assets/css/main.css']
css: ['~/assets/css/main.css', '~/assets/css/animations.scss']
}
```

You can omit the file extension for CSS/SCSS/Postcss/Less/Stylus/... files listed in the css array in your nuxt config file.

```js{}[nuxt.config.js]
export default {
css: ['~/assets/css/main', '~/assets/css/animations']
}
```

By omitting the extension, if you have a css file and decide to change to use sass for example, you won't have to update your nuxt.config as it will use the new extension once the filename remains the same.

<base-alert type="next">

See more on the [css property](/guides/configuration-glossary/configuration-css)
Expand Down
24 changes: 23 additions & 1 deletion content/en/guides/features/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ Nuxt.js will automatically guess the file type by its extension and use the appr

</base-alert>

### Style Extensions

You can omit the file extension for CSS/SCSS/Postcss/Less/Stylus/... files listed in the css array in your nuxt config file.

```js{}[nuxt.config.js]
export default {
css: ['~/assets/css/main', '~/assets/css/animations']
}
```

<base-alert>

If you have two files with the same name eg. main.scss and main.css, and don't add an extension in the css array eg. `css:['~/assets/css/main']`, then the files will be loaded in a specific order, first the css file and then the scss file.

</base-alert>

Default order: `['css', 'pcss', 'postcss', 'styl', 'stylus', 'scss', 'sass', 'less']`

<app-modal>
<code-sandbox :src="csb_link_pre-processors"></code-sandbox>
</app-modal>
Expand Down Expand Up @@ -364,6 +382,10 @@ The axios-module cannot be used in `nuxt.config.js`. You will need to import axi

## Further configuration

The `nuxt.config.js` has way more customization and configuration options! Check out all its keys in the glossary.
<base-alert type="next">

The `nuxt.config.js` has way more customization and configuration options! Check out all its keys in the [configuration glossary](/guides/configuration-glossary/configuration-build).

</base-alert>

<quiz :questions="questions"></quiz>