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
e7f7d22
commit
af6da09b55e75b91d31fd37784ca211437f18f29
caibinghong
authored
on 15 Jul 2021
Showing
4 changed files
package.json
project/demo/index.html
project/demo/index.js
vite.config.js
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: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.375", "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:login": "node build/build.js ./project/hivuiLogin", "build:main": "node build/run.js ./project/hivuiMain", "build:demo": "node build/run.js ./project/demo,./project/hivuiMain", "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.375", "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.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>EAP5-Admin-Login</title> <% if(!htmlWebpackPlugin.vite){%> <!--发布时 公共库--> <script src="/webpackDll/vuelibs.dll.js"></script> <script src="/webpackDll/elementui.dll.js"></script> <script src="/webpackDll/vendor.dll.js"></script> <%}%> <!--预览时 公共库--> <!-- <% if(htmlWebpackPlugin.vite==true){%> <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="https://unpkg.com/element-ui/lib/index.js"></script> <%}%> --> <script src="/eap.umd.js"></script> <script src="/project/setting/desktop/appsetting/js/1.0.0/appsetting.js" type="text/javascript"></script> </head> <body> <div id="app"></div> <% if(htmlWebpackPlugin.vite==true){%> <script type="module" src="./index.js"></script> <%}%> <!-- built files will be auto injected --> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>EAP5-Admin-Login</title> <% if(!htmlWebpackPlugin.vite){%> <script src="/webpackDll/vuelibs.dll.js"></script> <script src="/webpackDll/elementui.dll.js"></script> <script src="/webpackDll/vendor.dll.js"></script> <%}%> <script src="/eap.umd.js"></script> <script src="/project/setting/desktop/appsetting/js/1.0.0/appsetting.js" type="text/javascript"></script> </head> <body> <div id="app"></div> <% if(htmlWebpackPlugin.vite==true){%> <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> <!-- import Vue before Element --> <script src="https://unpkg.com/vue/dist/vue.js"></script> <!-- import JavaScript --> <script src="https://unpkg.com/element-ui/lib/index.js"></script> <script type="module" src="./index.js"></script> <%}%> <!-- built files will be auto injected --> </body> </html>
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 + "/"; } }); // console.log('hiSetting:', hiSetting) // console.log('ELEMENT:', ELEMENT) // console.log('Vue:', Vue) // console.log('Router:', Router) 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;
// import Vue from 'vue' // alert(Vue.version); // import ElementUI from 'element-ui'; // alert(ElementUI.version); import Vue from 'vue' import ElementUI from 'element-ui'; import "element-ui/lib/theme-chalk/index.css"; Vue.use(ElementUI) import App from './App.vue' import "hi-ui/lib/hi-ui.css"; import Router from 'vue-router' import { HiDataSetContainer } from "hi-ui" let hiSetting = HIVUI_SETTING; let DataSet = HiDataSetContainer;//vite才识别 // console.log('---1111---',DataSet); 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:', ElementUI) console.log('Vue:', Vue) console.log('Router:', Router) new Vue({ render: h => h(App), }).$mount('#app') // console.log(Vue,"import.meta.env",import.meta.env||process.env) // var baseURL = import.meta.env.VITE_APP_BASE_API||process.env.VITE_APP_BASE_API;
Ignore Space
Show notes
View
vite.config.js
// vite.config.js 利害浏览器自带的 es 动态导入,使项目冷启动 const { resolve } = require('path'); import { defineConfig, loadEnv } from 'vite' import { createVuePlugin } from "vite-plugin-vue2"; import vueJsx from '@vitejs/plugin-vue-jsx' import pageData from 'vite-plugin-pagedata' import { injectHtml } from 'vite-plugin-html'; const pageage = require("./package.json"); // https://vitejs.dev/config/ export default ({ mode }) => { process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; let aliases = {} let build = { sourcemap: false, //编译 //指定 多个 .html 文件作为入口点 rollupOptions: { // 请确保外部化那些你的库中不需要的依赖 // external: ['vue'], input: { main: resolve(__dirname, 'index.html'), nested: resolve(__dirname, 'nested/index.html') }, output: { format: 'umd', } } } if (mode == 'development') { aliases = { '@main': resolve(`${pageage.name == 'hi-vui-template' ? 'project' : pageage.name}/hivuiMain`), } console.log('aliases@main:', aliases['@main']); } else { } return defineConfig({ build: build, css: { preprocessorOptions: { less: { javascriptEnabled: true, } }, }, resolve: { extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue', '.dtvevt', '.dtv'], alias: aliases, }, plugins: [ injectHtml({ //向预览时注入变量,这个变量跟打包时 html-webpack-plugin 注入的一致,用户判断是否是编译状态 injectData:{ htmlWebpackPlugin:{ vite:true } } }), pageData({ varName:'scpRequestData' }), createVuePlugin(), vueJsx({ // options are passed on to @vue/babel-plugin-jsx }), ], optimizeDeps: { //vite 排除,并同时js 文件中不引用。如果有引用还是会取vite 模板缓存中的文件,这样就无法引用全局 // exclude:["vue","element-ui"] }, devServer: { port: 227, proxy: 'http://192.168.1.183:5001/' } }) };
// vite.config.js 利害浏览器自带的 es 动态导入,使项目冷启动 const { resolve } = require('path'); import { defineConfig, loadEnv } from 'vite' import { createVuePlugin } from "vite-plugin-vue2"; import vueJsx from '@vitejs/plugin-vue-jsx' import pageData from 'vite-plugin-pagedata' import { injectHtml } from 'vite-plugin-html'; const pageage = require("./package.json"); // https://vitejs.dev/config/ export default ({ mode }) => { process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }; let aliases = {} let build = { sourcemap: false, //编译 //指定 多个 .html 文件作为入口点 rollupOptions: { // 请确保外部化那些你的库中不需要的依赖 // external: ['vue'], input: { main: resolve(__dirname, 'index.html'), nested: resolve(__dirname, 'nested/index.html') }, output: { format: 'umd', } } } if (mode == 'development') { aliases = { '@main': resolve(`${pageage.name == 'hi-vui-template' ? 'project' : pageage.name}/hivuiMain`), } console.log('aliases@main:', aliases['@main']); } else { } return defineConfig({ build: build, css: { preprocessorOptions: { less: { javascriptEnabled: true, } }, }, resolve: { extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue', '.dtvevt', '.dtv'], alias: aliases, }, plugins: [ injectHtml({ //向预览时注入变量,这个变量跟打包时 html-webpack-plugin 注入的一致,用户判断是否是编译状态 injectData:{ htmlWebpackPlugin:{ vite:true } } }), pageData({ varName:'scpRequestData' }), createVuePlugin(), vueJsx({ // options are passed on to @vue/babel-plugin-jsx }), ], optimizeDeps: { // exclude:["vue","element-ui"]//预览时排不排都没有关系? // exclude:["hi-ui"],//冷启动时,排除的包 }, devServer: { port: 227, proxy: 'http://192.168.1.183:5001/' } }) };
Show line notes below