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

Serving assets in npm start #232

Closed
quanterion opened this issue Jan 18, 2016 · 7 comments
Closed

Serving assets in npm start #232

quanterion opened this issue Jan 18, 2016 · 7 comments
Labels

Comments

@quanterion
Copy link

I added to this starter image to /src/assets/img/test.png
After launching "npm start" the address
localhost:3000/assets/img/test.png is inaccessible, but address
localhost:3000/src/assets/img/test.png is working.

Which url should I set in image tag inside my html template?

@phil-lgr
Copy link

+1, was fighting to get fonts being loaded from url() in my css.

@PatrickJS
Copy link
Owner

the assets folder should be copied over to dist/assets and serving dist for example we;re using /assets/ for the icons https://github.com/AngularClass/angular2-webpack-starter/blob/master/src/index.html#L13...L25

@quanterion
Copy link
Author

1)So I need to copy /src/assets/ to dist/assets manually each time I change smth in assets folder?
2)What do you mean by serving dist? Should I change server:dev command in package.json to serve dist folder instead of root folder? Will hot reload be working then?

@tmramo
Copy link

tmramo commented Jan 19, 2016

Hi,

I am experiencing the same issue as RemKolomna.

Downloaded a (fresh) Webpack starter, installed it by running ‘npm install’ (with no issues at all). I started it with ‘npm start’ with Webpack reporting that the bundle is valid. When accessing localhost:3000, I cannot access the icons:

http://localhost:3000/assets/icon/favicon-16x16.png -> 404
http://localhost:3000/src/assets/icon/favicon-16x16.png -> 200

I am running Windows 10, with Node version 4.2.3 and npm version 2.14.7. I didn’t had any problems prior to copy-webpack-plugin and am thinking that it might be the cause of this issue.

@PatrickJS PatrickJS added the bug label Jan 19, 2016
@deleonio
Copy link
Contributor

Does anyone know why the whole src directory is accessible under dist?

The CopyWebpackPlugin does nothing!

@alvipeo
Copy link

alvipeo commented Jan 24, 2016

Actually, CopyWebpackPlugin works. According to setup it runs when you do 'npm run build:dev' but not when you 'npm start'. But the problem is there anyway - even if img file is copied to dist webserver returns 404. And this is really the big unknown for me...

@PatrickJS
Copy link
Owner

so the problem was that webpack-dev-server was serving dist/ in-memory so if you added another file to src/assets you need to rebuild for it to copy over to dist/ I changed the contentBase to use src so when you use assets/ it's poining to src/assets rather than dist/assets. closed via c6f50c8

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

6 participants