james last,深圳市教师招聘信息,陈怡曼无遮胸
vue项目用webpack打包想要修改静态资源路径等,找到项目根目录下的config文件夹,打开该文件夹下的index.js文件,默认如下:
// see http://vuejs-templates.github.io/webpack for documentation. var path = require('path') module.exports = { build: { env: require('./prod.env'), index: path.resolve(__dirname, '../dist/'), 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 }, dev: { env: require('./dev.env'), port: 8080, autoopenbrowser: true, assetssubdirectory: 'static', assetspublicpath: '/', proxytable: {}, // css sourcemaps off by default because relative paths are "buggy" // with this option, according to the css-loader readme // (https://github.com/webpack/css-loader#sourcemaps) // in our experience, they generally work as expected, // just be aware of this issue when enabling this option. csssourcemap: false } }
其中build.index:必须是本地文件系统上的绝对路径。会生成文件。
build.assetsroot:必须是本地文件系统上的绝对路径。
build.assetssubdirectory:编译出来的资源文件。
build.assetspublicpath:【资源的根目录】,这是通过http服务器运行的url路径。默认情况下,是根目录(/)。如果后台对静态资源url前缀要求,则需要改变这个路径。
build.productionsourcemap:在构建生产环境版本时是否开启source map。
以上这篇修改vue+webpack run build的路径方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
VUE+elementui组件在table-cell单元格中绘制微型echarts图
Vue通过getAction的finally来最大程度避免影响主数据呈现问题
vue 路由懒加载中给 Webpack Chunks 命名的方法
网友评论