Webpack: Must i specify the domain in publicPath for url() directive to work in CSS? -


my problem if don't specify complete domain in output.publicpath config option; url don't load (at least fonts).

my webpack config:

output: {   ...   publicpath: '/assets/' }, module: {    loaders: {     {        test: /\.less$/,        loader: "style!css?sourcemap!less?sourcemap"      },     {        test: /\.(png|jpg|svg|gif|eot|woff|ttf)$/,        loader: 'file-loader?name=[path][name]-[hash].[ext]'     }   } }, debug: true, devtool: 'eval' 

i have less file states:

@font-face {   font-family: 'new-sources';   src: url('../../fonts/sources-icons-rev-4.eot');   ... } 

my server in http://localhost:5000.

when check generated css while debugging in chrome see has been replaced by:

@font-face {   font-family: 'new-sources';   src: url(/assets/sdk/v1/fonts/sources-icons-rev-4-fad6f81d012ba56b350abdc714d1fa5a.eot);   ... } 

which seems correct! doesn't work chrome dev tools report error: "failed decode downloaded font: http://localhost:5000/widgets/damian/9789/en" indicating tried load font url, url current location, i'm serving html. , don't know why trying fetch font url.

if go to: http://localhost:5000/assets/sdk/v1/fonts/sources-icons-rev-4-fad6f81d012ba56b350abdc714d1fa5a.eot. works.

everything solved when change publicpath to: 'http://localhost:5000/assets/'. that's want avoid, , in case understand why happens.

my guess, since style-loader, add css blob, css losses concept of 'current domain' urls don't have domain in it, act strange.

but @ same time, should happening uses webpack css, , haven't seen comment it. :s

thanks!!!

found it. @diunarlist on webpack's gitter.

it's because using sourcemap style-loader. check https://github.com/webpack/style-loader/issues/55

with source-maps, style loader uses blob, requires absolute urls work.

without source-maps uses inline style tag, there no problem.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -