We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.安装 resolve-url-loader
npm i resolve-url-loader --save-dev
2.修改webpack配置文件
output: { publicPath: '/' } { test: /\.scss$/, loaders: ['style', 'css', 'resolve-url', 'sass'] }
1.安装 postcss-loader postcss-assets
npm install postcss-loader postcss-assets --save-dev
2.例子
output: { publicPath: '/' } postcss: function() { return [ require('postcss-assets')({ relative: true, // 配置图片所在位置, 例如我的图片存在与 static 文件夹里面 loadPaths: [path.resolve(__dirname, '../static')], }), ] }
.css { background: resolve('css.png') ; }
css-loader 开启 sourceMap 功能时,output.publicPath 一定填写一个网址,例如 http://localhost:3000/,填其他一切背景图片都无法正确显示。issue
css-loader
sourceMap
output.publicPath
http://localhost:3000/
The text was updated successfully, but these errors were encountered:
还有其他解决方法?
Sorry, something went wrong.
@XIAOGUIGUI 是这两种解决方法都没用么?如果是开启 sourceMap 的话那没办法,只能 publicPath 填url.
publicPath
还是没解决。。。
No branches or pull requests
解决方法1
1.安装 resolve-url-loader
2.修改webpack配置文件
解决方法2
1.安装 postcss-loader postcss-assets
2.例子
特别注意
css-loader
开启sourceMap
功能时,output.publicPath
一定填写一个网址,例如http://localhost:3000/
,填其他一切背景图片都无法正确显示。issueThe text was updated successfully, but these errors were encountered: