This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: removed the `useRelativePath` option. It is dangerously and break url when you use multiple entry points.
- Loading branch information
1 parent
d5eb823
commit 9853db1
Showing
11 changed files
with
203 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,60 @@ | ||
{ | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"name": {}, | ||
"regExp": {}, | ||
"name": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"instanceof": "Function" | ||
} | ||
] | ||
}, | ||
"outputPath": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"instanceof": "Function" | ||
} | ||
] | ||
}, | ||
"publicPath": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"instanceof": "Function" | ||
} | ||
] | ||
}, | ||
"context": { | ||
"type": "string" | ||
}, | ||
"publicPath": {}, | ||
"outputPath": {}, | ||
"useRelativePath": { | ||
"type": "boolean" | ||
}, | ||
"emitFile": { | ||
"type": "boolean" | ||
}, | ||
"regExp": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"instanceof": "RegExp" | ||
} | ||
] | ||
} | ||
}, | ||
"errorMessages": { | ||
"name": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#name)", | ||
"outputPath": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#outputpath)", | ||
"publicPath": "should be {String} or {Function} (https://github.com/webpack-contrib/file-loader#publicpath)", | ||
"context": "should be {String} (https://github.com/webpack-contrib/file-loader#context)", | ||
"useRelativePath": "should be {Boolean} (https://github.com/webpack-contrib/file-loader#userelativepath)", | ||
"emitFile": "should be {Boolean} (https://github.com/webpack-contrib/file-loader#emitfile)" | ||
"emitFile": "should be {Boolean} (https://github.com/webpack-contrib/file-loader#emitfile)", | ||
"regExp": "should be {String} or {RegExp} (https://github.com/webpack-contrib/file-loader#regexp)" | ||
}, | ||
"additionalProperties": true | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,58 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`errors validation errors 1`] = ` | ||
exports[`validation errors 1`] = ` | ||
"File Loader Invalid Options | ||
options.useRelativePath should be boolean | ||
options should NOT have additional properties | ||
" | ||
`; | ||
|
||
exports[`validation errors 2`] = ` | ||
"File Loader Invalid Options | ||
options.name should be string | ||
options.name should pass \\"instanceof\\" keyword validation | ||
options.name should match some schema in anyOf | ||
" | ||
`; | ||
|
||
exports[`validation errors 3`] = ` | ||
"File Loader Invalid Options | ||
options.outputPath should be string | ||
options.outputPath should pass \\"instanceof\\" keyword validation | ||
options.outputPath should match some schema in anyOf | ||
" | ||
`; | ||
|
||
exports[`validation errors 4`] = ` | ||
"File Loader Invalid Options | ||
options.publicPath should be string | ||
options.publicPath should pass \\"instanceof\\" keyword validation | ||
options.publicPath should match some schema in anyOf | ||
" | ||
`; | ||
|
||
exports[`validation errors 5`] = ` | ||
"File Loader Invalid Options | ||
options.context should be string | ||
" | ||
`; | ||
|
||
exports[`validation errors 6`] = ` | ||
"File Loader Invalid Options | ||
options.emitFile should be boolean | ||
" | ||
`; | ||
|
||
exports[`validation errors 7`] = ` | ||
"File Loader Invalid Options | ||
options.regExp should be string | ||
options.regExp should pass \\"instanceof\\" keyword validation | ||
options.regExp should match some schema in anyOf | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,57 @@ | ||
import loader from '../src'; | ||
|
||
describe('errors', () => { | ||
it('validation errors', () => { | ||
const err = () => | ||
loader.call({ | ||
query: { useRelativePath: 1 }, | ||
emitFile: true, | ||
}); | ||
|
||
expect(err).toThrow(); | ||
expect(err).toThrowErrorMatchingSnapshot(); | ||
describe('validation', () => { | ||
it('errors', () => { | ||
const validate = (options) => | ||
loader.call( | ||
Object.assign( | ||
{}, | ||
{ | ||
resourcePath: 'image.png', | ||
query: options, | ||
emitFile: () => {}, | ||
} | ||
), | ||
'a { color: red; }' | ||
); | ||
|
||
expect(() => | ||
validate({ unknown: 'unknown' }) | ||
).toThrowErrorMatchingSnapshot(); | ||
|
||
expect(() => validate({ name: '[path][name].[ext]' })).not.toThrow(); | ||
expect(() => | ||
validate({ | ||
name: () => '[hash].[ext]', | ||
}) | ||
).not.toThrow(); | ||
expect(() => validate({ name: true })).toThrowErrorMatchingSnapshot(); | ||
|
||
expect(() => validate({ outputPath: 'assets' })).not.toThrow(); | ||
expect(() => | ||
validate({ | ||
outputPath: () => 'assets', | ||
}) | ||
).not.toThrow(); | ||
expect(() => validate({ outputPath: true })).toThrowErrorMatchingSnapshot(); | ||
|
||
expect(() => validate({ publicPath: 'assets' })).not.toThrow(); | ||
expect(() => | ||
validate({ | ||
publicPath: () => 'assets', | ||
}) | ||
).not.toThrow(); | ||
expect(() => validate({ publicPath: true })).toThrowErrorMatchingSnapshot(); | ||
|
||
expect(() => validate({ context: 'assets' })).not.toThrow(); | ||
expect(() => validate({ context: true })).toThrowErrorMatchingSnapshot(); | ||
|
||
expect(() => validate({ emitFile: true })).not.toThrow(); | ||
expect(() => validate({ emitFile: false })).not.toThrow(); | ||
expect(() => validate({ emitFile: 'true' })).toThrowErrorMatchingSnapshot(); | ||
|
||
expect(() => validate({ regExp: /image\.png/ })).not.toThrow(); | ||
expect(() => validate({ regExp: 'image\\.png' })).not.toThrow(); | ||
expect(() => validate({ regExp: true })).toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.