Description
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
// webpack.config
{
test: /\.less$/,
use: [{
loader: 'css-loader',
query: {
importLoaders: 1,
minimize: !isDevEnv,
sourceMap: isDevEnv,
},
{ loader: 'less-loader' }
}]
}
// index.less
@import './iconfont.css'
// iconfont.css
@font-face {
font-family: "iconfont";
src: url('/src/assets/font/iconfont.eot');
// ...
}
If so, the iconfont.eot won't be packed to a module/file to the dist directory and won't be added to the devServer when I request the page.
If I add an option/query such as root: process.cwd()
or alias: {'/src': '../../../'}
to the css-loader
, the iconfont.eot will be packed to the dist directory but still won't be added to the devServer when I request the page because the url in iconfont.css
still is '/src/assets/font/iconfont.eot'
rather than '/static/assets/font/iconfont.eot'
. But if I use relative path like '../../../assets/font/iconfont.eot' in the url(...)
, it will automatically transform the '/src/assets/font/iconfont.eot' -> '/static/assets/font/iconfont.eot'
Another question it will not throw an Error like can't find the module '/src/assets/font/iconfont.eot'(seems like begin with '~/' or '/' will cause no throw) in xxxx
. This is a little bad. If I use relative path and give it a wrong path, it will throw.
By the way, seems like this is not about less or less-loader, the problem still exists even I just use css.
If the current behavior is a bug, please provide the steps to reproduce.
See above.
What is the expected behavior?
It will works even I use absolute path.
I have searched on google and webpack/css-loader/postcss issues, and have tried many workaround such as resolve.modules, options.url, options.root, options.alias, all of them can'r resolve this.
Have not tried postcss-url
or resolve-url-loader
, but I think that's not the key because I wan't to know why this won't work rather than how to make it works.
Please mention other relevant information such as your webpack version, Node.js version and Operating System.
MacOs
Node 8.11.3
Webpack 3.12.0
css-loader 0.28.9
Thanks.