Webpack: Problem with static path, and production build

Created on 13 Apr 2016  路  6Comments  路  Source: vuejs-templates/webpack

Hi,

I'm trying to import fonts.

I put them into assets and made a link to it, fonts seem to be resolved when running "npm run dev",

screen2

but i keep getting :

screen1

But if i add a "/" after static i get the font !!!

Same thing when building with "npm run build" the links in the generated index.html in static doesn't match the actual url

screen3

instead of /static/app etc.

I couldn't figure out how to add a "/" or change anything in config files ...

bug

Most helpful comment

I don't you guys are running into the same issue - but could you please try upgrading vue-cli to the latest version and confirm that things are fixed with a fresh project?

All 6 comments

I met a similar issue today. When I run npm run dev and open localhost:8080, it always show a 404 error says that '/static/logo.png' does not exist

I modified the dev-server.js file to fix this problem.
in line 56, change

var staticPath = path.join(config.build.assetsPublicPath, config.build.assetsSubDirectory);
app.use(staticPath, express.static('./static'));

to

var staticPath = config.build.assetsPublicPath + config.build.assetsSubDirectory;
app.use(staticPath, express.static('./static'));

it seems this problem results from that path.join() would change '/' to '\' in windows.

@unhealthy @Hemric Does the latest master with path.resolve instead of path.join fix the problem?

I don't you guys are running into the same issue - but could you please try upgrading vue-cli to the latest version and confirm that things are fixed with a fresh project?

@unhealthy indeed ... but this didn't work for me
@chrisvfritz I tried to use path.resolve as shown, but it didn't seemed to fix the problem
@yyx990803 I just updated vue-cli and refresh all the config files and ... everything seems to work perfectly now, in dev and in the production build !

thank you very much guys :+1: !

@Hemric good to know!

@yyx990803 well my problem has been fixed in the new version vue-cli, thanks very much!

Was this page helpful?
0 / 5 - 0 ratings