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

options.name should be string #215

Closed
ghost opened this issue Oct 4, 2017 · 9 comments
Closed

options.name should be string #215

ghost opened this issue Oct 4, 2017 · 9 comments

Comments

@ghost
Copy link

ghost commented Oct 4, 2017

file-loader: 1.1.4
webpack: 3.6.0
npm: 5.3.0
node: 8.6.0
...
options: {
name: 'static/media/[name].[ext]',
}
....

Module build failed: Validation Error
File Loader Invalid Options
options.name should be string

@michael-ciniawsky
Copy link
Member

Please show your full webpack.config.js

@ghost
Copy link
Author

ghost commented Oct 4, 2017

@michael-ciniawsky attached my webpack config.

Thanks,
Daniel

webpack.config.dev.js.txt

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Oct 4, 2017

@DanielG2002 Please update tourl-loader to >= v0.6.1. It has had a bug to not allow additional properties and therefore seem to be failing on the additional name prop. Otherwise feel free to reopen the issue and we maybe need to disable the type check for name then. Also try a minimum example in case it is still failing, to ensure it isn't another config related bug

@ghost
Copy link
Author

ghost commented Oct 4, 2017

@michael-ciniawsky tried with url-loader v0.6.2 with same result

@joshwiens
Copy link
Member

I'm doing something very similar for work & this is reproducible in 0.6.1 & not 0.6.2.

@DanielG2002 - Double check that you don't have a package cached by npm / yarn as well as verifying what's in your lock file ( if you are using one )

@ghost
Copy link
Author

ghost commented Oct 5, 2017

@michael-ciniawsky 100% confirmed! 0.6.2 has the same issue.

package-lock.json (double checked also in node_modules directory)
"url-loader": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/url-loader/-/url-loader-0.6.2.tgz",
"integrity": "sha512-h3qf9TNn53BpuXTTcpC+UehiRrl0Cv45Yr/xWayApjw6G8Bg2dGke7rIwDQ39piciWCWrC+WiqLjOh3SUp9n0Q==",
"dev": true,
"requires": {
"loader-utils": "1.1.0",
"mime": "1.4.1",
"schema-utils": "0.3.0"
}
}

@joshwiens
Copy link
Member

@DanielG2002 - I assume given you didn't link a repo that whatever you are working on isn't public.

Is that based off of create react app?

@ghost
Copy link
Author

ghost commented Oct 5, 2017

@michael-ciniawsky Exactly, is a private repo. Yes, was created using create react app.

Clearly the problem is the transfer of the value option.name from url-loader to file-loader; in my url-loader, is a function and your file-loader expect only a string type.

For example:

{
test: [/.bmp$/, /.gif$/, /.jpe?g$/, /.png$/, /.svg$/, /.wav/],
loader: require.resolve('url-loader'),
options: {
limit: 8192,
name: (filePath) => {
if (filePath.indexOf('KanbanView-BackgroundImage') > 0)
return 'static/media/[name].[ext]'
else
return 'static/media/[name].[hash:8].[ext]'
}
},
},

@joshwiens
Copy link
Member

Yeah, that part I get. I just wanted to fork whatever that is so we can test the rest of the schema enforcement PR's against it + the angular-cli ( covers a vast majority of the use cases )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants