GitBucket
4.6.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull Requests
Labels
Milestones
Wiki
08335
/
hivui-platform-template
hivui平台项目模板
Browse code
add
master
1 parent
a075298
commit
7769c9bec897c37cad358b28fa9e09b5c2472e0a
caibinghong
authored
on 19 Jul 2021
Showing
4 changed files
babel.config.js
build/bin/preview.sh
package.json
project/demo/index.js
Ignore Space
Show notes
View
babel.config.js
//vite 启动,与webpack 编译都能识别这个 process.env.NODE_ENV // console.log('babel.config.js process.env.NODE_ENV:', process.env.NODE_ENV) let config = {};// 默认vite 预览不做任何配置 ,否则有影响vite 对jsx 预览 if (process.env.NODE_ENV == "production") { config = { "presets": [ // "@vue/babel-preset-jsx" [ //做语法转换,并注入函数 //1、存在每个js 文件都注入函数使文件体积变大 "@babel/preset-env" ] ], "plugins": [ "babel-plugin-transform-vite-meta-env",//转换环境变量,vite几个参数同步到webpack编译中 "@vue/babel-plugin-transform-vue-jsx",//打包jsx 写的vue 组件 [ //2、配置这个插件,并通过@babel/runtime 库来解决 1 的问题 ,将注入的转为包的引用 解决了代码复用和最终文件体积大的问题 //3、@babel/runtime 里存放的是Babel做语法转换的辅助函数 ,进化版@babel/runtime-corejs3 除了包含Babel做语法转换的辅助函数,也包含了core-js的API转换函数 //4、 解决1的问题 ,那么2也存在问题会影响原window下的核心api,这样污染环境。因此此插件的corejs3解决这个问题,但并引用@babel/runtime-corejs3 "@babel/plugin-transform-runtime", { "corejs": 3 // 指定 runtime-corejs 的版本,目前有 2 3 两个版本 } ], [ "component", { "libraryName": "hi-ui",//按需引用,不用时要去掉这个配置 "style": false,//不需要加载css // "camel2Dash": false//不需要驼峰转换成 - } ] ] } } module.exports = config;
//vite 启动,与webpack 编译都能识别这个 process.env.NODE_ENV // console.log('babel.config.js process.env.NODE_ENV:', process.env.NODE_ENV) let config = {};// 默认vite 预览不做任何配置 ,否则有影响vite 对jsx 预览 if (process.env.NODE_ENV == "production") { config = { "presets": [ "@vue/babel-preset-jsx" // [ // //做语法转换,并注入函数 // //1、存在每个js 文件都注入函数使文件体积变大 // "@babel/preset-env" // ] ], "plugins": [ "babel-plugin-transform-vite-meta-env",//转换环境变量,vite几个参数同步到webpack编译中 "@vue/babel-plugin-transform-vue-jsx",//打包jsx 写的vue 组件 [ //2、配置这个插件,并通过@babel/runtime 库来解决 1 的问题 ,将注入的转为包的引用 解决了代码复用和最终文件体积大的问题 //3、@babel/runtime 里存放的是Babel做语法转换的辅助函数 ,进化版@babel/runtime-corejs3 除了包含Babel做语法转换的辅助函数,也包含了core-js的API转换函数 //4、 解决1的问题 ,那么2也存在问题会影响原window下的核心api,这样污染环境。因此此插件的corejs3解决这个问题,但并引用@babel/runtime-corejs3 "@babel/plugin-transform-runtime", { "corejs": 3 // 指定 runtime-corejs 的版本,目前有 2 3 两个版本 } ], [ "component", { "libraryName": "hi-ui", "style": false,//不需要加载css // "camel2Dash": false//不需要驼峰转换成 - } ] ] } } module.exports = config;
Ignore Space
Show notes
View
build/bin/preview.sh
0 → 100644
#!/bin/bash cd /mobileproject/$1/XcxProject && npm run dev:h5 --port $2
Ignore Space
Show notes
View
package.json
{ "name": "hi-vui-template", "version": "1.0.3", "description": "A hi-vui-template project", "author": "caibinghong <caibinghong@163.com>", "scripts": { "pm2:start": "npm run rm:vite && pm2 start processes.json", "pm2:restart": "npm run rm:vite && pm2 restart all", "pm2:stop": "pm2 stop all", "pm2:log": "pm2 logs ", "pm2:cpu": "pm2 monit ", "pm2:kill": "pm2 delete all", "dev": "vite --host", "vite-build": "vite build", "vite-serve": "vite preview", "rm:vite": "rimraf node_modules/.vite", "start": "npm run dev", "build": "node build/run.js", "build:debug": "node build/build.js", "build:login": "node build/build.js ./project/hivuiLogin", "build:main": "node build/run.js ./project/hivuiMain", "build:demo": "node build/run.js ./project/demo", "build:dll": "webpack --config=build/webpack.dll.js", "copyassets": "node build/copyBaseAssets.js" }, "dependencies": { "@babel/runtime-corejs3": "^7.14.6", "@vue/babel-helper-vue-jsx-merge-props": "^1.2.1", "axios": "^0.21.1", "classnames": "^2.3.1", "enquire.js": "^2.1.6", "hi-ui": "^1.1.390", "lodash": "^4.17.21", "md5": "^2.3.0", "qs": "^6.10.1", "screenfull": "^5.1.0", "sortablejs": "^1.13.0", "vue": "^2.6.12", "vue-draggable-resizable": "^2.3.0", "vue-gemini-scrollbar": "^2.0.1", "vue-jstree": "^2.1.6", "vue-router": "^3.5.1", "vuex": "^3.6.2" }, "devDependencies": { "@babel/core": "^7.14.5", "@babel/plugin-transform-runtime": "^7.14.5", "@babel/preset-env": "^7.14.5", "@vitejs/plugin-vue-jsx": "^1.1.5", "@vue/babel-plugin-transform-vue-jsx": "^1.2.1", "@vue/babel-preset-jsx": "^1.2.4", "add-asset-html-webpack-plugin": "^3.2.0", "autoprefixer": "^10.2.6", "babel-loader": "^8.2.2", "babel-plugin-component": "^1.1.1", "babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-transform-vite-meta-env": "^1.0.3", "css-loader": "^5.2.6", "css-minimizer-webpack-plugin": "^3.0.2", "dotenv": "^10.0.0", "file-loader": "^6.2.0", "html-webpack-plugin": "^5.3.2", "less": "^4.1.1", "less-loader": "^10.0.0", "mini-css-extract-plugin": "^1.6.1", "parallel-webpack": "^2.6.0", "postcss-import": "^14.0.2", "postcss-loader": "^6.1.0", "postcss-url": "^10.1.3", "rimraf": "^3.0.2", "semver": "^5.4.1", "shelljs": "^0.7.8", "speed-measure-webpack-plugin": "^1.5.0", "svg-sprite-loader": "^3.5.2", "terser-webpack-plugin": "^5.1.4", "url-loader": "^4.1.1", "vite": "2.3.7", "vite-plugin-html": "^2.0.7", "vite-plugin-pagedata": "^1.0.3", "vite-plugin-vue2": "^1.6.2", "vue-loader": "^15.9.7", "vue-style-loader": "^4.1.3", "vue-template-compiler": "^2.6.12", "webpack": "^5.40.0", "webpack-cli": "^4.7.2", "webpack-merge": "^5.8.0" }, "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" } }
{ "name": "hi-vui-template", "version": "1.0.3", "description": "A hi-vui-template project", "author": "caibinghong <caibinghong@163.com>", "scripts": { "pm2:start": "npm run rm:vite && pm2 start processes.json", "pm2:restart": "npm run rm:vite && pm2 restart all", "pm2:stop": "pm2 stop all", "pm2:log": "pm2 logs ", "pm2:cpu": "pm2 monit ", "pm2:kill": "pm2 delete all", "dev": "vite --host", "vite-build": "vite build", "vite-serve": "vite preview", "rm:vite": "rimraf node_modules/.vite", "start": "npm run dev", "build": "node build/run.js", "build:debug": "node build/build.js", "build:login": "node build/build.js ./project/hivuiLogin", "build:main": "node build/run.js ./project/hivuiMain", "build:demo": "node build/run.js ./project/demo", "build:dll": "webpack --config=build/webpack.dll.js", "copyassets": "node build/copyBaseAssets.js" }, "dependencies": { "@babel/runtime-corejs3": "^7.14.6", "@vue/babel-helper-vue-jsx-merge-props": "^1.2.1", "axios": "^0.21.1", "classnames": "^2.3.1", "enquire.js": "^2.1.6", "hi-ui": "^1.1.384", "lodash": "^4.17.21", "md5": "^2.3.0", "qs": "^6.10.1", "screenfull": "^5.1.0", "sortablejs": "^1.13.0", "vue": "^2.6.12", "vue-draggable-resizable": "^2.3.0", "vue-gemini-scrollbar": "^2.0.1", "vue-jstree": "^2.1.6", "vue-router": "^3.5.1", "vuex": "^3.6.2" }, "devDependencies": { "@babel/core": "^7.14.5", "@babel/plugin-transform-runtime": "^7.14.5", "@babel/preset-env": "^7.14.5", "@vitejs/plugin-vue-jsx": "^1.1.5", "@vue/babel-plugin-transform-vue-jsx": "^1.2.1", "@vue/babel-preset-jsx": "^1.2.4", "add-asset-html-webpack-plugin": "^3.2.0", "autoprefixer": "^10.2.6", "babel-loader": "^8.2.2", "babel-plugin-component": "^1.1.1", "babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-transform-vite-meta-env": "^1.0.3", "css-loader": "^5.2.6", "css-minimizer-webpack-plugin": "^3.0.2", "dotenv": "^10.0.0", "file-loader": "^6.2.0", "html-webpack-plugin": "^5.3.2", "less": "^4.1.1", "less-loader": "^10.0.0", "mini-css-extract-plugin": "^1.6.1", "parallel-webpack": "^2.6.0", "postcss-import": "^14.0.2", "postcss-loader": "^6.1.0", "postcss-url": "^10.1.3", "rimraf": "^3.0.2", "semver": "^5.4.1", "shelljs": "^0.7.8", "speed-measure-webpack-plugin": "^1.5.0", "svg-sprite-loader": "^3.5.2", "terser-webpack-plugin": "^5.1.4", "url-loader": "^4.1.1", "vite": "2.3.7", "vite-plugin-html": "^2.0.7", "vite-plugin-pagedata": "^1.0.3", "vite-plugin-vue2": "^1.6.2", "vue-loader": "^15.9.7", "vue-style-loader": "^4.1.3", "vue-template-compiler": "^2.6.12", "webpack": "^5.40.0", "webpack-cli": "^4.7.2", "webpack-merge": "^5.8.0" }, "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" } }
Ignore Space
Show notes
View
project/demo/index.js
// vite 预览开发情况下排除,改引用全局 // if(import.meta.env.MODE=="production"){ // // alert(1) // // import Vue from 'vue'; // // import ELEMENT from 'element-ui'; // // import "element-ui/lib/theme-chalk/index.css"; // // Vue.use(ELEMENT) // }else{ // alert(2) // } import App from './App.vue' import "hi-ui/lib/hi-ui.css"; import {HiDataSetContainer} from 'hi-ui' let hiSetting = HIVUI_SETTING; let DataSet = HiDataSetContainer;//vite才识别 Vue.prototype.$dsContainer = new DataSet({ request: hiSetting.request, saveUrl: hiSetting.saveUrl, queryUrl: hiSetting.queryUrl, datasetUrl: hiSetting.datasetUrl, policyUrl: hiSetting.policyUrl, cacheKeyPrefix: function () { return window.location.hash + "/"; } }); new Vue({ render: h => h(App), }).$mount('#app') // console.log("import.meta.env", import.meta.env) // var baseURL = import.meta.env.VITE_APP_BASE_API||process.env.VITE_APP_BASE_API;
// vite 预览开发情况下排除,改引用全局 // if(import.meta.env.MODE=="production"){ // // alert(1) // // import Vue from 'vue'; // // import ELEMENT from 'element-ui'; // // import "element-ui/lib/theme-chalk/index.css"; // // Vue.use(ELEMENT) // }else{ // alert(2) // } // import App from './App.vue' // import "hi-ui/lib/hi-ui.css"; require(ELEMENT); // import { HiDataSetContainer,HiPagination } from "hi-ui" // let hiSetting = HIVUI_SETTING; // let DataSet = HiDataSetContainer;//vite才识别 // Vue.prototype.$dsContainer = new DataSet({ // request: hiSetting.request, // saveUrl: hiSetting.saveUrl, // queryUrl: hiSetting.queryUrl, // datasetUrl: hiSetting.datasetUrl, // policyUrl: hiSetting.policyUrl, // cacheKeyPrefix: function () { // return window.location.hash + "/"; // } // }); // console.log('hiSetting:', hiSetting) // console.log('ELEMENT:', ELEMENT) // console.log('Vue:', Vue) // console.log('Router:', Router) // console.log('HiPagination:', HiPagination) // new Vue({ // render: h => h(App), // }).$mount('#app') // console.log("import.meta.env", import.meta.env) // var baseURL = import.meta.env.VITE_APP_BASE_API||process.env.VITE_APP_BASE_API;
Show line notes below