You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 17, 2021. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 17, 2021. It is now read-only.
When checking with the latest stuff in npm, I cannot get file-loader to emit a JSON file to the destination directory, when said to use a JSON file as input.
Minimal example:
Create a directory with three files, x.json, x.js, and webpack.config.js:
I want to use file-loader because I want the file to be copied to dist, not it to be embedded in the JavaScript bundle. The fact is that, due to the way it is used, afaik I need the app to download a file with that name, with the JSON content in it.
The type: "javascript/auto" you're proposing is for using webpack own plugin/loader instead of `file-loader right? If that's the case, that's not going to work in my case, except if it produces a separate file...
{type: 'javascript/auto',test: /\.json$/,use: ['file-loader'],include: /\.\/config/// for e.g, but better to only copy particular JSON files (not all)}
Reacted by Jesus M. Gonzalez-Barahona, Ryan Graham, scarletsky, bitttttten, Alexander Fallenstedt, Anton (Tonix), Gabriel Kuslap, Pratchaya and Aoda Zhang
Activity
alexander-akait commentedon Mar 12, 2018
@jgbarah known feat, webpack handle
jsonuse own plugins/loaders, usetype: "javascript/auto"(as here https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsDefaulter.js#L50). also why you usefile-loader?. It is disallow shaking tree.jgbarah commentedon Mar 12, 2018
Thanks @evilebottnawi.
I want to use file-loader because I want the file to be copied to
dist, not it to be embedded in the JavaScript bundle. The fact is that, due to the way it is used, afaik I need the app to download a file with that name, with the JSON content in it.The
type: "javascript/auto"you're proposing is for using webpack own plugin/loader instead of `file-loader right? If that's the case, that's not going to work in my case, except if it produces a separate file...michael-ciniawsky commentedon Mar 12, 2018
webpack.config.js
jgbarah commentedon Mar 12, 2018
It works. Thanks!!!
tonix-tuft commentedon Oct 1, 2019
@michael-ciniawsky That's great! How can I tell Webpack where to save the file and how should its name be?
Tried this but it doesn't work, I get the following error:
Mydayyy commentedon Oct 11, 2019
@tonix-tuft
Try this: