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
- Host: GitHub
- URL: https://github.com/cap32/file-loader-relative-path-bug
- Owner: Cap32
- Created: 2017-10-31T08:18:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-05T02:57:29.000Z (over 8 years ago)
- Last Synced: 2025-01-27T13:48:28.779Z (over 1 year ago)
- Language: JavaScript
- Size: 51.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```