问题描述1.项目路径如下图图片描述2.sass目录下reset.scss.footer{background: url("/static/img/top.png") no-repeat;}3.npm run build图片路径错误,调试模式下在/static前面改为./static可以加载出图片如果将reset.scss footer改为./static/img/top.png webpack 报错提示 This relative module was not found这里好像只能用绝对路径图片描述相关代码1.buid/utils.jsif (options.extract) { return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader',
publicPath: '../../',
})
}
sass配置
scss: generateLoaders('sass').concat(
{
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, '../static/sass/main.scss')
}
}2.config/index.jsbuild: {// Template for index.htmlindex: path.resolve(__dirname, '../dist/index.html'),// PathsassetsRoot: path.resolve(__dirname, '../dist'),assetsSubDirectory: 'static',assetsPublicPath: './',}如何将static/img图片路径build之后改为相对路径呢?
添加回答
举报
0/150
提交
取消