Nuxt.js: [css-loader] Problem with static files

Created on 21 Aug 2017  路  8Comments  路  Source: nuxt/nuxt.js

Hi,
I have a code:

@font-face {
  font-family: icomoon;
  src: url('/fonts/icomoon/icomoon.woff2') format('woff2');

  font-weight: normal;
  font-style: normal;
}

After I updated Nuxt from 0.10.6 to rc5 I got an error:(before update it works)

 in ./node_modules/css-loader?{"minimize":true,"importLoaders":1,"sourceMap":true,"root":"~","alias":{"/static":"D://Projects//Vue//***//src//static","/assets":"D://Projects//Vue//***//src//assets"}}!./node_modules/postcss-loader/lib?{"sourceMap":true,"plugins":[null,null,{"version":"6.0.9","plugins":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"postcssPlugin":"postcss-cssnext","postcssVersion":"6.0.9"}]}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true}!./src/css/main.scss
Module not found: Error: Can't resolve 'fonts/icomoon/icomoon.woff2' in 'D:\Projects\Vue\Smart Landing\smart-landing-client\src\css'
 @ ./node_modules/css-loader?{"minimize":true,"importLoaders":1,"sourceMap":true,"root":"~","alias":{"/static":"D://Projects//Vue//***//src//static","/assets":"D://Projects//Vue//***//src//assets"}}!./node_modules/postcss-loader/lib?{"sourceMap":true,"plugins":[null,null,{"version":"6.0.9","plugins":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"postcssPlugin":"postcss-cssnext","postcssVersion":"6.0.9"}]}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true}!./src/css/main.scss 6:140737-140775
 @ ./src/css/main.scss
 @ ./node_modules/babel-loader/lib?{"presets":["vue-app","stage-0","es2015"],"plugins":["transform-decorators-legacy","transform-class-properties"],"babelrc":false,"cacheDirectory":true}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./.nuxt/App.vue
 @ ./.nuxt/App.vue
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi webpack-hot-middleware/client?name=client&reload=true ./.nuxt/client.js

This bug report is available on Nuxt.js community (#c1277)
available soon bug-confirmed

Most helpful comment

I updated the css-loader to handle aliases starting with /, let's hope it could be merged pretty fast!

See https://github.com/webpack-contrib/css-loader/pull/597

All 8 comments

Hi. This is because rc5 tries to correctly load and hash font assets. If not is inside assets, please use '~/assets/fonts/..` instead.

PS: Are you using custom postcss rules?

@pi0 thank you for your answer, but the fonts are placing in static/, and ~/static/fonts/.. doesn't work

Even if inside ~/assets it doesn't work if there is a space inside font file name (i.e. Averta Bold.otf)

Hi @krasevych

Indeed it's because of css-loaders aliases, I'm looking at it.

I updated the css-loader to handle aliases starting with /, let's hope it could be merged pretty fast!

See https://github.com/webpack-contrib/css-loader/pull/597

Any update on this ? I have same problem and can't use rc5 now

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredreich picture jaredreich  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

bimohxh picture bimohxh  路  3Comments

maicong picture maicong  路  3Comments