aurelia / aurelia/cli

[BUG] with webpack, inlineView deps (<require from="./style.css"></require>) doesn't work

Open
#911 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
402
Forks
134
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a bug report**

* **Library Version:**
0.34.0

**Please tell us about your environment:**
* **Operating System:**
all

* **Node Version:**
all

* **NPM Version:**
all

* **Browser:**
all

* **Language:**
all

* **Loader/bundler:**
Webpack

**Current behavior:**

`aurelia-webpack-plugin` did its job to bring in the inlineView required "./style.css". But our cli `webpack.config.js` prevented it from working properly.

It's caused by:
```js
// CSS required in JS/TS files should use the style-loader that auto-injects it into the website
// only when the issuer is a .js/.ts file, so the loaders are not applied inside html templates
{
test: /\.css$/i,
issuer: [{ not: [{ test: /\.html$/i }] }],
use: extractCss ? [{
loader: MiniCssExtractPlugin.loader
},
'css-loader'
] : ['style-loader', ...cssRules]
},
{
test: /\.css$/i,
issuer: [{ test: /\.html$/i }],
// CSS required in templates cannot be extracted safely
// because Aurelia would try to require it again in runtime
use: cssRules
},
```

The "./style.css" dep loaded from inlineView is NOT from issuer html, so it ended up with style-loader instead of packed as a module.

* **What is the expected behavior?**

The dep loaded by inlineView should be treated same as dep loaded by html file.

* **What is the motivation / use case for changing the behavior?**

Need to update the rules to avoid this regression. But I don't know webpack enough to fix this.

cc @jods4 this bug prevents aurelia/webpack-plugin#107 from working.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.