An open API service indexing awesome lists of open source software.

https://github.com/cap32/file-loader-relative-path-bug


https://github.com/cap32/file-loader-relative-path-bug

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

# file-loader-relative-path-bug

This repo shows some bugs in [file-loader](https://github.com/webpack-contrib/file-loader) when `useRelativePath` is `true` and `context` is not setted (using `issuer.context`).

To run this repo, please clone this repo and run `npm install`, and then run `npm run build`.

If multi entries imported the same file (`./images/1.jpg` in this example), and if their issuer contexts are different (`./html/foo/` and `./html/` in this example), the compiled urls are wrong.

### Src

```
|-- html
| |-- bar.html
| `-- foo
| `-- foo.html
`-- images
`-- 1.jpg
```

### Build `foo.html` only

```
|-- foo.js
|-- html
| `-- foo
| `-- foo.html
`-- images
`-- 1.jpg
```

`./html/foo/foo.html` content is ✅

```html

```

### Build `bar.html` only

```
|-- bar.js
|-- html
| `-- bar.html
`-- images
`-- 1.jpg
```

`./html/bar.html` content is ✅

```html

```

### Build both `foo.html` and `bar.html`

```
|-- bar.js
|-- foo.js
|-- html
| |-- bar.html
| `-- foo
| `-- foo.html
`-- images
`-- 1.jpg
```

**Sometimes the results are:**

`./html/foo/foo.html` content is ✅

```html

```

`./html/bar.html` content is ❌

```html

```

**And sometimes are:**

`./html/foo/foo.html` content is ❌

```html

```

`./html/bar.html` content is ✅

```html

```