Skip to content

Commit

Permalink
feat(webpack): add possibility to add options for the sass implementa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
ernscht committed Nov 4, 2024
1 parent c2e3485 commit 964568d
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
3 changes: 2 additions & 1 deletion packages/nitro-webpack/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Config:
- `true` or `{}` will activate scss support
- `{ publicPath: '../' }` provide a separate public path for stylesheets. By default, webpack uses the value from 'output.publicPath'. (only relevant for production build)
- `{ implementation: require('node-sass') }` gives the possibility to use 'node-sass' as sass implementation. (you have to add 'node-sass' as a dev-dependency in your project)
- `{ sassOptions: { ... } }` gives the possibility to add options for the ['dart-sass'](https://sass-lang.com/documentation/js-api/interfaces/options/) or ['node-sass'](https://github.com/sass/node-sass/#options) implementation (e.g. ignore some deprecations for dart-sass with `silenceDeprecations: [...]`)

#### `options.rules.hbs`

Expand All @@ -77,7 +78,7 @@ Config:

Config:

- `true` or `{}` will activate handlebars handlebars precompiled templates support
- `true` or `{}` will activate handlebars precompiled templates support
- `{ include: [] }` additionally adds include config to rule
- `{ exclude: [] }` additionally adds exclude config to rule

Expand Down
3 changes: 2 additions & 1 deletion packages/nitro-webpack/webpack-config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ module.exports = (options = { rules: {}, features: {} }) => {
// css & scss
if (options.rules.scss) {
const scssLoaderOptions = {
...(options.rules.scss.implementation && { implementation: options.rules.scss.implementation })
...(options.rules.scss.implementation && { implementation: options.rules.scss.implementation }),
...(options.rules.scss.sassOptions && { sassOptions: options.rules.scss.sassOptions }),
};
webpackConfig.module.rules.push({
test: /\.s?css$/,
Expand Down
3 changes: 2 additions & 1 deletion packages/nitro-webpack/webpack-config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ module.exports = (options = { rules: {}, features: {} }) => {
...(options.rules.scss.publicPath && { publicPath: options.rules.scss.publicPath })
};
const scssLoaderOptions = {
...(options.rules.scss.implementation && { implementation: options.rules.scss.implementation })
...(options.rules.scss.implementation && { implementation: options.rules.scss.implementation }),
...(options.rules.scss.sassOptions && { sassOptions: options.rules.scss.sassOptions }),
};
webpackConfig.module.rules.push({
test: /\.s?css$/,
Expand Down
7 changes: 6 additions & 1 deletion packages/project-nitro-twig/config/webpack/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ const options = {
rules: {
js: true,
ts: false,
scss: true,
scss: {
sassOptions: {
quietDeps: true,
silenceDeprecations: ['color-functions', 'global-builtin', 'import', 'legacy-js-api'],
},
},
hbs: true,
woff: true,
image: true,
Expand Down
5 changes: 3 additions & 2 deletions packages/project-nitro-twig/project/docs/nitro-webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ Config:
Config:

- `true` or `{}` will activate scss support
- `{ stylelint: true }` additionally adds stylelint live linting feature (only relevant for development build)
- `{ publicPath: '../' }` provide a separate public path for stylesheets. By default, webpack uses the value from 'output.publicPath'. (only relevant for production build)
- `{ implementation: require('node-sass') }` gives the possibility to use 'node-sass' as sass implementation. (you have to add 'node-sass' as a dev-dependency in your project)
- `{ sassOptions: { ... } }` gives the possibility to add options for the ['dart-sass'](https://sass-lang.com/documentation/js-api/interfaces/options/) or ['node-sass'](https://github.com/sass/node-sass/#options) implementation (e.g. ignore some deprecations for dart-sass with `silenceDeprecations: [...]`)

#### `options.rules.hbs`

Expand All @@ -82,7 +83,7 @@ Config:

Config:

- `true` or `{}` will activate handlebars handlebars precompiled templates support
- `true` or `{}` will activate handlebars precompiled templates support
- `{ include: [] }` additionally adds include config to rule
- `{ exclude: [] }` additionally adds exclude config to rule

Expand Down
7 changes: 6 additions & 1 deletion packages/project-nitro-typescript/config/webpack/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ const options = {
rules: {
js: false,
ts: true,
scss: true,
scss: {
sassOptions: {
quietDeps: true,
silenceDeprecations: ['color-functions', 'global-builtin', 'import', 'legacy-js-api'],
},
},
hbs: true,
woff: true,
image: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ Config:
Config:

- `true` or `{}` will activate scss support
- `{ stylelint: true }` additionally adds stylelint live linting feature (only relevant for development build)
- `{ publicPath: '../' }` provide a separate public path for stylesheets. By default, webpack uses the value from 'output.publicPath'. (only relevant for production build)
- `{ implementation: require('node-sass') }` gives the possibility to use 'node-sass' as sass implementation. (you have to add 'node-sass' as a dev-dependency in your project)
- `{ sassOptions: { ... } }` gives the possibility to add options for the ['dart-sass'](https://sass-lang.com/documentation/js-api/interfaces/options/) or ['node-sass'](https://github.com/sass/node-sass/#options) implementation (e.g. ignore some deprecations for dart-sass with `silenceDeprecations: [...]`)

#### `options.rules.hbs`

Expand All @@ -82,7 +83,7 @@ Config:

Config:

- `true` or `{}` will activate handlebars handlebars precompiled templates support
- `true` or `{}` will activate handlebars precompiled templates support
- `{ include: [] }` additionally adds include config to rule
- `{ exclude: [] }` additionally adds exclude config to rule

Expand Down
5 changes: 3 additions & 2 deletions packages/project-nitro/project/docs/nitro-webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ Config:
Config:

- `true` or `{}` will activate scss support
- `{ stylelint: true }` additionally adds stylelint live linting feature (only relevant for development build)
- `{ publicPath: '../' }` provide a separate public path for stylesheets. By default, webpack uses the value from 'output.publicPath'. (only relevant for production build)
- `{ implementation: require('node-sass') }` gives the possibility to use 'node-sass' as sass implementation. (you have to add 'node-sass' as a dev-dependency in your project)
- `{ sassOptions: { ... } }` gives the possibility to add options for the ['dart-sass'](https://sass-lang.com/documentation/js-api/interfaces/options/) or ['node-sass'](https://github.com/sass/node-sass/#options) implementation (e.g. ignore some deprecations for dart-sass with `silenceDeprecations: [...]`)

#### `options.rules.hbs`

Expand All @@ -82,7 +83,7 @@ Config:

Config:

- `true` or `{}` will activate handlebars handlebars precompiled templates support
- `true` or `{}` will activate handlebars precompiled templates support
- `{ include: [] }` additionally adds include config to rule
- `{ exclude: [] }` additionally adds exclude config to rule

Expand Down

0 comments on commit 964568d

Please sign in to comment.