Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/dotcom-build-css/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {

This plugin adds a [rule] to the Webpack configuration to handle `.css` files. It calls the [css-loader] package to load and parse the source files. The CSS is optimised using [css-minimizer-webpack-plugin], which runs [cssnano] under the hood. The [mini-css-extract-plugin] is added to generate `.css` files and the [webpack-fix-style-only-entries] to clean up any empty JavaScript bundles.

The CSS loader has `url()` resolution disabled as we don't use, nor recommend, the function currently.
The CSS loader has `url()` resolution disabled as we don't use, nor recommend, the function currently. We also prevent importing CSS from Javascript files, as that's incompatible with the Asset Loader in production.

[rule]: https://webpack.js.org/configuration/module/#rule
[css-loader]: https://github.com/webpack-contrib/css-loader
Expand Down
3 changes: 3 additions & 0 deletions packages/dotcom-build-css/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export class PageKitCssPlugin {

compiler.options.module.rules.push({
test: [/\.css$/],
issuer: {
not: [/\.(js|ts)x?$/],
},
use: cssRule()
})

Expand Down
2 changes: 1 addition & 1 deletion packages/dotcom-build-sass/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Sass supports both relative paths and paths that can be resolved within your `no
new PageKitSassPlugin({ includePaths: [path.resolve('./path-to-sass-files')] })
```

The CSS loader has `url()` resolution disabled as we don't use, nor recommend, the function currently.
The CSS loader has `url()` resolution disabled as we don't use, nor recommend, the function currently. We also prevent importing Sass from Javascript files, as that's incompatible with the Asset Loader in production.

[rule]: https://webpack.js.org/configuration/module/#rule
[@financial-times/dotcom-build-css]: ../dotcom-build-css
Expand Down
3 changes: 3 additions & 0 deletions packages/dotcom-build-sass/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export class PageKitSassPlugin {

compiler.options.module.rules.push({
test: [/\.sass|scss$/],
issuer: {
not: [/\.(js|ts)x?$/],
},
use: [
// Load generated CSS using the same logic as
// @financial-times/dotcom-build-css
Expand Down