preboot/angularjs-webpack

Can't load ressources when "npm run build"

ttvz opened this issue · 4 comments

ttvz commented

Hi,

The starter is working well in dev mode but the index.html generated doesn't load resources after the "npm run build":
index.html:10 GET file:///css/app.css net::ERR_FILE_NOT_FOUND
index.html:13 GET file:///app.a4613de7b169ac687194.js net::ERR_FILE_NOT_FOUND
/img/favicon.ico:1 GET file:///img/favicon.ico net::ERR_FILE_NOT_FOUND

Even when i am doing node cmd on the generated app.js file, i have a "ReferenceError: window is not defined" !

Never used webpack with Angular so How can i use this starter on production ?

TY

For npm run build on your local machine

  1. Update line# 49 of webpack.config.js (i.e. remove '/' if isProd flag is true)

Final State publicPath: isProd ? '' : 'http://localhost:8080/'

  1. Remove/Comment

For deploying it on Server (i.e. nginx or another) follow these instructions

Do above changes as per the server-specific deployment.

phra commented

@chamanklalwani if some changes are required to the starter kit just send a PR with the required changes.

@phra I don't think any change required to the starter kit. It's just @ttvz is facing issue related to npm run build.

I was facing the same issue too on my machine, and I fixed it by following above-mentioned instructions. Opening dist/index.html file generated from npm run build in the browser will load nothing. Because It's unable to load resources. So I figured out an extra '/' being appended to the resources file and I removed it from below mentioned line when isProd flag is true.

Line# 49 publicPath: isProd ? '/' : 'http://localhost:8080/'

phra commented

closing..