Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webpack-contrib/file-loader
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.4
Choose a base ref
...
head repository: webpack-contrib/file-loader
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.5
Choose a head ref
  • 5 commits
  • 7 files changed
  • 3 contributors

Commits on Oct 1, 2017

  1. docs: Add leading slash to path option examples (#203)

    The current documentation is incorrect, or at least misleading. For `publicPath` or `outputPath`, if you omit the leading slash, no directory is created, and the files are placed in `output.path` as usual.
    
    If this is the desired behavior, it should be documented as such; if it's not, I'm happy to submit a PR to `file-loader` which would make it care less about whether there's a trailing slash.
    tstirrat15 authored and joshwiens committed Oct 1, 2017
    Copy the full SHA
    38e4b0c View commit details

Commits on Oct 5, 2017

  1. Copy the full SHA
    bc73688 View commit details
  2. Copy the full SHA
    fbfb160 View commit details
  3. Copy the full SHA
    5ae410f View commit details
  4. chore(release): 1.1.5

    joshwiens committed Oct 5, 2017
    Copy the full SHA
    f321874 View commit details
Showing with 41 additions and 10 deletions.
  1. +10 −0 CHANGELOG.md
  2. +23 −3 README.md
  3. +1 −1 package-lock.json
  4. +1 −1 package.json
  5. +1 −3 src/options.json
  6. +4 −1 test/Errors.test.js
  7. +1 −1 test/__snapshots__/Errors.test.js.snap
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="1.1.5"></a>
## [1.1.5](https://github.com/webpack/file-loader/compare/v1.1.4...v1.1.5) (2017-10-05)


### Bug Fixes

* **schema:** allow `name` to be a `{Function}` (`options.name`) ([#216](https://github.com/webpack/file-loader/issues/216)) ([fbfb160](https://github.com/webpack/file-loader/commit/fbfb160))



<a name="1.1.4"></a>
## [1.1.4](https://github.com/webpack/file-loader/compare/v1.1.3...v1.1.4) (2017-09-30)

26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ Emits `file.png` as file in the output directory and returns the public URL

|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`name`**|`{String}`|`[hash].[ext]`|Configure a custom filename template for your file|
|**`name`**|`{String\|Function}`|`[hash].[ext]`|Configure a custom filename template for your file|
|**`context`**|`{String}`|`this.options.context`|Configure a custom file context, defaults to `webpack.config.js` [context](https://webpack.js.org/configuration/entry-context/#context)|
|**`publicPath`**|`{String\|Function}`|[`__webpack_public_path__ `](https://webpack.js.org/api/module-variables/#__webpack_public_path__-webpack-specific-)|Configure a custom `public` path for your files|
|**`outputPath`**|`{String\|Function}`|`'undefined'`|Configure a custom `output` path for your files|
@@ -68,6 +68,8 @@ Emits `file.png` as file in the output directory and returns the public URL

You can configure a custom filename template for your file using the query parameter `name`. For instance, to copy a file from your `context` directory into the output directory retaining the full directory structure, you might use

#### `{String}`

**webpack.config.js**
```js
{
@@ -78,6 +80,24 @@ You can configure a custom filename template for your file using the query param
}
```

#### `{Function}`

**webpack.config.js**
```js
{
loader: 'file-loader',
options: {
name (file) {
if (env === 'development') {
return '[path][name].[ext]'
}

return '[hash].[ext]'
}
}
}
```

#### `placeholders`

|Name|Type|Default|Description|
@@ -123,7 +143,7 @@ You can specify custom `output` and `public` paths by using `outputPath`, `publi
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
publicPath: 'assets'
publicPath: 'assets/'
}
}
```
@@ -136,7 +156,7 @@ You can specify custom `output` and `public` paths by using `outputPath`, `publi
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
outputPath: 'images'
outputPath: 'images/'
}
}
```
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "file-loader",
"version": "1.1.4",
"version": "1.1.5",
"author": "Tobias Koppers @sokra",
"description": "file loader module for webpack",
"license": "MIT",
4 changes: 1 addition & 3 deletions src/options.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"name": {},
"regExp": {},
"context": {
"type": "string"
5 changes: 4 additions & 1 deletion test/Errors.test.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,10 @@ import loader from '../src';

describe('Errors', () => {
test('Validation Error', () => {
const err = () => loader.call({ query: { name: 1 }, emitFile: true });
const err = () => loader.call({
query: { useRelativePath: 1 },
emitFile: true,
});

expect(err).toThrow();
expect(err).toThrowErrorMatchingSnapshot();
2 changes: 1 addition & 1 deletion test/__snapshots__/Errors.test.js.snap
Original file line number Diff line number Diff line change
@@ -11,6 +11,6 @@ exports[`Errors Validation Error 1`] = `
File Loader Invalid Options
options.name should be string
options.useRelativePath should be boolean
"
`;