关于vue项目直接点击dist文件夹下面的index.html文件使项目在浏览器显示,需配置两个文件,
config/index.js
build: {
assetsPublicPath: './',
}
build/utils.js
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader',
publicPath:'../../',//这里更改css的路径这样图片就能正常显示
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}