question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"asset not found" Error while file is present in webpack-assets.json

See original GitHub issue

Hi,

I came across this issue and I am not sure if it’s due to the unusual folder structure of my project or if it’s a bug from webpack-isomorphic-tools.

The issue can be reproduced on https://github.com/happypoulp/webpack-isomorphic/tree/issue-production

After running npm run webpack if you run npm start to start the application server, you’ll see errors being emitted by webpack-isomorphic tools about some assets not being found.

Here is the debug output:

.local ~/Codes/webpack-iso > npm start

> webpack-iso@1.0.0 start /Users/fbonnefont/Codes/webpack-iso
> NODE_ENV=dev node app/bin/server.js

[webpack-isomorphic-tools] [debug] instantiated webpack-isomorphic-tools with options {
  "debug": true,
  "assets": {
    "json": {
      "extensions": [
        "json"
      ]
    },
    "scss": {
      "extensions": [
        "scss"
      ]
    }
  },
  "webpack_assets_file_path": "webpack-assets.json",
  "webpack_stats_file_path": "webpack-stats.json"
}
[webpack-isomorphic-tools] [debug] entering development mode
[webpack-isomorphic-tools] [debug] registering require() hooks for assets
[webpack-isomorphic-tools] [debug]  registering a require() hook for *.json
[require-hook] [debug] Hooking into *.json files loading
[require-hook] [debug] -----------------------------------------------
[require-hook] [debug] Overriding an already existing require() hook
[require-hook] [debug] for file extension .json
[require-hook] [debug] -----------------------------------------------
[webpack-isomorphic-tools] [debug]  registering a require() hook for *.scss
[require-hook] [debug] Hooking into *.scss files loading
FAKE SERVER
[webpack-isomorphic-tools] [debug] flushing require() caches
[require-hook] [debug] require() hook fired for /Users/fbonnefont/Codes/webpack-iso/app/src/base.scss
[webpack-isomorphic-tools] [debug] require() called for /Users/fbonnefont/Codes/webpack-iso/app/src/base.scss
[webpack-isomorphic-tools] [debug]  requiring ./src/base.scss
[require-hook] [debug] require() hook fired for /Users/fbonnefont/Codes/webpack-iso/app/webpack-assets.json
[require-hook] [debug] Fallback to original loader
[webpack-isomorphic-tools] [error] asset not found: ./src/base.scss
[require-hook] [debug] require() hook fired for /Users/fbonnefont/Codes/webpack-iso/app/src/mod-1.scss
[webpack-isomorphic-tools] [debug] require() called for /Users/fbonnefont/Codes/webpack-iso/app/src/mod-1.scss
[webpack-isomorphic-tools] [debug]  requiring ./src/mod-1.scss
[webpack-isomorphic-tools] [error] asset not found: ./src/mod-1.scss
[require-hook] [debug] require() hook fired for /Users/fbonnefont/Codes/webpack-iso/app/src/file.json
[webpack-isomorphic-tools] [debug] require() called for /Users/fbonnefont/Codes/webpack-iso/app/src/file.json
[webpack-isomorphic-tools] [debug]  requiring ./src/file.json
[webpack-isomorphic-tools] [error] asset not found: ./src/file.json
...

What puzzles me is that for example ./src/base.scss is actually present in webpack-assets.json but under the path ./app/src/base.scss… The project_base_path I gave to webpack-isomorphic-tools server is the same as the one used in my webpack.config.js as suggested in your docs but I think that the issue might come from that setup.

Do you know what the issue could come from?

Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
AndrewRayCodecommented, Sep 10, 2018

I know this library is deprecated and I can’t tell if this is the same issue, but after upgrading to Webpack 4 I’m getting lots of

[webpack-isomorphic-tools] [error] asset not found

repeated for all of my css imports

and a huge stack trace starting with:

[0] [webpack-isomorphic-tools/plugin] [error] TypeError: require(...) is not a function
[0]     at Object.<anonymous> (containers/Game/Game.scss.webpack-module:2:87)
0reactions
catamphetaminecommented, May 21, 2016

FYI I’m posting this in every issue and PR to notify whoever may be interested: today I’ve released an alternative helper library called universal-webpack. It takes a different approach than webpack-ismorphic-tools and instead of hacking Node.js require() calls it just compiles all code with target: 'node' webpack configuration option. As a result, all Webpack plugins and features are supported. If you think you might need that here’s an example project: https://github.com/halt-hammerzeit/webpack-react-redux-isomorphic-render-example

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't generate webpack-assets.json with webpack-isomorphic ...
The reason the assets file is not generated is because you have integrated webpack-dev-server into your server.js .
Read more >
Asset Management - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
The Asset Pipeline - Ruby on Rails Guides
Raise an Error When an Asset is Not Found; Turning Digests Off ... If a file exists at public/assets/rails.png it is served by...
Read more >
Static Asset Handling - Vite
The behavior is similar to webpack's file-loader . The difference is that the import can be either using absolute public paths (based on...
Read more >
assets-webpack-plugin - npm
This plug-in outputs a json file with the paths of the generated assets so you can find them from somewhere else. Example output:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found