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

can't add assets #36

Closed
ahmed-anas opened this issue Jul 19, 2017 · 6 comments
Closed

can't add assets #36

ahmed-anas opened this issue Jul 19, 2017 · 6 comments
Labels

Comments

@ahmed-anas
Copy link

ahmed-anas commented Jul 19, 2017

I'm submitting a ...

[x] bug report => check the README and search github for a similar issue or PR before submitting
[x] support request => check the README and search github for a similar issue or PR before submitting
[ ] feature request

Current behavior
adding <img src="assets/pic.jpg" /> to app.component.html (and a pic.jpg in the assets folder) gives the error: Can't resolve './assets/pic.jpg'

changing the path of the asset to relative, i.e making it <img src="../assets/pic.jpg" /> gives the error: Error: Path variable [chunkhash] not implemented in this context: assets/pic.[chunkhash].jpg. Assets should not be relative so adding the ../ shouldn't work in any case.

I run using: npm run build:universal-prod; npm run serve;
Expected/desired behavior

It should work. Or perhaps this is configured to work with different sort of paths? If so, please advice.

Please tell us about your environment:
Windows 10

  • Browser: all

  • **Quick Solution: ** changing chunkhash to hash in the webpack.common.js file seems to fix this error though I'm not sure what complications that might have. Although the path would need to be relative to the current location, and ideally we should just be able to do assets/pic.jpg or something of the sort.

@artemsoliar
Copy link

artemsoliar commented Jul 19, 2017

I use like this <img src="/assets/pic.jpg" />

@ahmed-anas
Copy link
Author

ahmed-anas commented Jul 19, 2017

@artemsoliar In this scenario webpack doesn't add the image to the generated output public folder and I have 404 errors.

I'm using the bare ng-seed/universal master branch for testing this. The steps I do are

  • insert a pic.jpg file in assets
  • add <img src="/assets/pic.jpg" />" in app.component.html`
  • run npm run build:universal-prod
  • run npm run serve

@artemsoliar
Copy link

artemsoliar commented Jul 19, 2017

in webpack.config.js file add like this

 new copyWebpackPlugin([
     {
          from: `${root(settings.paths.src.client.assets.root)}/pic.jpg`,
          to: './pic.jpg'
        },]

more https://github.com/kevlened/copy-webpack-plugin

@ahmed-anas
Copy link
Author

@artimSoliar thanks, that helped. Not an ideal solution but good enough.

@theomathieubhvr
Copy link
Contributor

theomathieubhvr commented Jul 25, 2017

You can also add folders path to copy directories:

https://github.com/ng-seed/universal/blob/master/config/webpack.config.js#L26

@fulls1z3 fulls1z3 changed the title [support request / bug]: can't add assets [question]: can't add assets Jul 27, 2017
fulls1z3 pushed a commit that referenced this issue Aug 2, 2017
@fulls1z3
Copy link
Owner

fulls1z3 commented Aug 2, 2017

@ahmed-anas, @artemsoliar, @theomathieubhvr done 👍

@fulls1z3 fulls1z3 changed the title [question]: can't add assets [question] can't add assets Aug 10, 2017
fulls1z3 pushed a commit that referenced this issue Sep 9, 2017
* chore(package): update deps

Closes #14
Closes #36
Closes #38
fulls1z3 pushed a commit that referenced this issue Sep 9, 2017
* chore(package): update deps

Closes #14
Closes #36
Closes #38
fulls1z3 pushed a commit that referenced this issue Sep 9, 2017
* chore(package): update deps

Closes #14
Closes #36
Closes #38
@fulls1z3 fulls1z3 changed the title [question] can't add assets can't add assets Sep 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants