내 vue (2.0) + webpack 프로젝트에서 vue-html-loader를 설정했지만 내 .vue 파일에서 img 태그가 정적 src 이미지를로드 할 수 없습니다.vue + webpack project img can not load 정적 src
<img src="/web/img/[email protected]" srcset="/web/img/[email protected]" />
내 브라우저는 항상 404 오류가 나올 :
module: {
loaders: [
...
{
test: /\.html$/,
exclude: /node_modules/,
loaders: ['html', 'html-minify']
}
, {
test: /\.vue$/,
loader: 'vue'
}
...
]
},
vue: {
...
html: {
root: path.resolve(__dirname, './source/static'),
attrs: ['img:src', 'img:srcset']
},
loaders: {
css: ExtractTextPlugin.extract("css"),
sass: ExtractTextPlugin.extract("css!sass")
}
},
resolve: {
root: [
path.resolve('./source')
],
extensions: ['', '.js', '.json', '.scss', '.html', '.css', '.vue'],
alias: {
'vue': 'vue/dist/vue.js'
}
},
아래는 내 .vue 파일입니다 다음은 내 웹팩 설정입니다. 누군가가 같은 문제를 겪었나요?
정적 이미지의 경우 'url-loader'가 필요하다고 생각합니다. vue-cli가 사용하는 [webpack] (https://github.com/vuejs-templates/webpack) 템플릿을 강력히 추천합니다. https://github.com/vuejs-templates/webpack/blob/master/template/build/webpack.base.conf.js#L70 – Phil
@Phi URL 로더를 추가했습니다. 작동하지 않는 버그가 있습니다. – Yuga