类别:媒体报道 发布时间:2021-01-08 浏览人次:
4、config - index.js中把build这个命令复制一份改成testing(此步为了打包到不同文件夹)
build: { env: require('./prod.env'), // index: path.resolve(__dirname, '../'), // Paths assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: '/mshop/', * Source Ma凡科抠图 productionSourceMap: true, // configuration/devtool/#production devtool: '#source-map', // 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 --pression-webpack-plugin productionGzip: false, productionGzipExtensions: ['js', 'css'], // Run mand 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 testing: { env: require('./prod.env'), index: path.resolve(__dirname, '../'), assetsRoot: path.resolve(__dirname, '../testing'), 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 --pression-webpack-plugin productionGzip: false, productionGzipExtensions: ['js', 'css'], // Run mand 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
5、修改build- webpack.prod.conf文件
修改filename
new HtmlWebpackPlugin({ filename: process.env.type == '"testing"' config.testing.index : config.build.index
修改output
output: { path: process.env.type == '"testing"' config.testing.assetsRoot : config.build.assetsRoot,
6、修改build- build.js文件
路径都修改为根据正式、测试环境判断(不然执行npm run testing, npm run build命令时输出的文件有问题)
代码如下:rm(path.join(process.env.type == '"testing"' config.testing.assetsRoot : config.build.assetsRoot, process.env.type == '"testing"' config.testing.assetsSubDirectory : config.build.assetsSubDirectory), err = {
7、根据不同环境配置不同域名地址
let baseURL if (process.env.NODE_ENV === 'production') { if (process.env.type === 'testing') { // 测试环境 baseUrl = '测试环境地址' } else { // 正式环境 baseUrl = '正式环境地址' } else { // 本地环境 baseUrl = '本地环境地址'
最后执行:
npm run testing 就会执行测试环境配置的地址,并生成testing文件夹
npm run build就会执行正式环境配置的地址,并生成dist文件夹
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持凡科。
详细说明vue.js依据不一样自然环境(宣布、检测)装包到不一样文件目录 本文关键详细介绍了详细说明vue.js依据不一样自然环境(宣布、检测)装包到不一样文件目录,网编感觉挺好的...
2021-01-08招聘人数:19职位信息1、根据公司的业务发展规划、完善公司培训体系;2、制定公司培训计划,并落地实施;3、开发、完善并讲授部分通用课程,编制相应的培训教材并持续优化;4、...
2021-01-08今日大家来聊一聊互联网营销推广中的社区论坛营销推广,一切营销推广方式的核心理念全是放之四海而皆准的,大家都了解,但是搞好却其实不简易。一切营销推广的基本都来源于人...
2021-01-08vue2.0的虚似DOM3D渲染构思剖析 vue2.0选用了虚似DOM来替代对真正DOM的实际操作,最终根据某类体制来进行对真正DOM的升级,3D渲染主视图。本文关键详细介绍了vue2.0的虚似DOM3D渲染,必...
2021-01-08seo优化能够为网站产生许多益处,可是许多公司还没有有搞好提前准备,或是除此试着seo优化因为工作经验不够,不明白技术性造成主题活动经常挫败,接下去详细介绍seo优化没法圆满...
2021-01-08招聘人数:11职位信息岗位职责:1、负责公司品牌/产品形象创意及设计出品的负责和执行;2、根据每月制定的营销活动设计相关广告Banner、海报并对效果进行跟踪;3、根据网络推广的...
2021-01-08