Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an exception for manifest.json when loading as json, fixes #558 #565

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,18 @@ module.exports = {
// allow it implicitly so we also enable it.
{
test: /\.json$/,
exclude: /\/manifest.json$/,
loader: 'json'
},
// A special case for manifest.json to place it into build root directory.
{
test: /\/manifest.json$/,
include: [paths.appSrc],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I’m not sure about is whether it should be in src. I’m leaning towards putting it on the top level because you can’t import it from code now—you’ll get a string. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaearon sure, can you please explain why should it load differently from the top level in the code and differently from the template? I've tried some configurations and can't get it to load differently even though it's in the top level (by top level you mean template dir right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I wasn't clear. There is no way to make it load differently depending on context. Since we want it to resolve to filename, I wanted to move it away from src folder. The reason is that people normally expect that they can import JS/JSON inside src folder and treat it as a module. So it would be weird if src/manifest.json somehow was treated specially and you couldn't import it as a module from, for example, src/index.js. However we never officially supported importing modules from outside src folder so in this case special behavior seems like fair game. Does this make sense?

loader: 'file',
query: {
name: 'manifest.json?[hash:8]'
}
},
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// In production, they would get copied to the `build` folder.
Expand Down
10 changes: 10 additions & 0 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,18 @@ module.exports = {
// allow it implicitly so we also enable it.
{
test: /\.json$/,
exclude: /\/manifest.json$/,
loader: 'json'
},
// A special case for manifest.json to place it into build root directory.
{
test: /\/manifest.json$/,
include: [paths.appSrc],
loader: 'file',
query: {
name: 'manifest.json?[hash:8]'
}
},
// "file" loader makes sure those assets end up in the `build` folder.
// When you `import` an asset, you get its filename.
{
Expand Down