Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

vue项目打包

vue项目打包的时候,发现配置的是如下命令:
    "build:work": "vue-cli-service build --mode work",
    "build:ut": "vue-cli-service build --mode ut",
    "build:prod": "vue-cli-service build"

image.png

image.png

image.png

ut的没看到就这三个env文件

我该怎么选择打包命令呢?

选择的 build:prod

vue打包上线:

1,有env文件,将文件中的ip地址改成线上的
2,先把router(路由)里面的 mode:'history' 注释
const router = new VueRouter({
 // mode: 'history', (就是这里注释,否则需要后端帮忙整改)
  base: process.env.BASE_URL,
  routes
})
3,在根目录创建一个vue.config.js,添加以下以下内容
将publicPath: '/', 改成 publicPath: './', 如下:
module.exports = {
    publicPath: './',
}


4,vue打包运行报错(Cannot assign to read only property 'exports' of object '#<Object>')
在目录下babel.config.js中添加配置如下
module.exports = {
    presets: [
        '@vue/app'
    ],
    sourceType: 'unambiguous' //目的是让babel明确区分ES6导入导出方式与common.js导入导出方式
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
npm run build:prod

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...