先贴上webpak.base.config.js关于图片的代码
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
小于10k的图片都形成了base64码正常显示
但是超过的显示不了,css属性为这样
完整路径为这样
config.index.js的代码如下
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
},
如果将上面的assetsPublicPath按照部分网上的更改为'/'的话则所有打包后的引用路径为这样
file:///D:/static/js/app.77e13a999be27db608eb.js
就没有在项目目录下css写在VUE文件里,图片文件放在src的平级目录static里
是我没跑在服务器上的