框架源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
7.2 KiB

4 years ago
  1. const path = require("path");
  2. // const { name } = require("./package");
  3. const uc = require("upper-case");
  4. const loadSdkPlugin = require("./webpack_plugins/tis-loadsdk-plugin");
  5. const pxtoviewport = require("postcss-px-to-viewport");
  6. // const injectSdks = require('./webpack_plugins/tis-inject-sdk')
  7. // const createTisplatformPlugin =require('./webpack_plugins/tis-create-manifest');
  8. function resolve(dir) {
  9. return path.join(__dirname, dir);
  10. }
  11. const port = 7000; // dev port
  12. const ROOT_DIR_NAME = resolve("").split(path.sep).pop();
  13. const name = uc(ROOT_DIR_NAME);
  14. module.exports = {
  15. /**
  16. * You will need to set publicPath if you plan to deploy your site under a sub path,
  17. * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
  18. * then publicPath should be set to "/bar/".
  19. * In most cases please use '/' !!!
  20. * Detail: https://cli.vuejs.org/config/#publicpath
  21. */
  22. productionSourceMap: process.env.VUE_APP_DEBUG === "debug" || process.env.NODE_ENV === "development",
  23. publicPath: `/${name}/`,
  24. outputDir: `dist/${name}`,
  25. // assetsDir: "static",
  26. filenameHashing: false,
  27. // tweak internal webpack configuration.
  28. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  29. devServer: {
  30. // host: '0.0.0.0',
  31. hot: true,
  32. disableHostCheck: true,
  33. // port,
  34. overlay: {
  35. warnings: false,
  36. errors: true
  37. },
  38. headers: {
  39. "Access-Control-Allow-Origin": "*"
  40. },
  41. contentBase: ["lib", "sdk"],
  42. proxy: {
  43. "/ws/": {
  44. target: "ws://localhost:9999/",
  45. ws: true,
  46. changeOrigin: true
  47. // pathRewrite:{
  48. // "^/ws":"ws://10.12.16.173:3806/ws/ch1"
  49. // }http://10.12.16.219
  50. },
  51. "/tisstfw/": {
  52. target: "http://10.12.16.219:3806",
  53. changeOrigin: true
  54. },
  55. "/TIS_COMPONENT_MAP2D": {
  56. target: "http://localhost:7001",
  57. changeOrigin: true
  58. },
  59. "/KT_SJDB": {
  60. target: "http://localhost:7000",
  61. changeOrigin: true
  62. },
  63. "/KeyLogin/": {
  64. target: "http://10.12.16.219:3806",
  65. changeOrigin: true
  66. },
  67. "/207S_MLYY/": {
  68. target: "http://10.12.16.219:3806",
  69. changeOrigin: true
  70. },
  71. "/tisframework/": {
  72. target: "http://10.12.16.219:3806",
  73. changeOrigin: true
  74. },
  75. "/tisyhgl/": {
  76. target: "http://10.12.18.100:3806",
  77. changeOrigin: true
  78. }
  79. }
  80. },
  81. lintOnSave: false,
  82. // chainWebpack:config=>{
  83. // config.plugins.delete('prefetch')
  84. // },
  85. // 自定义webpack配置
  86. configureWebpack: {
  87. externals: {
  88. "tisui": "TIS",//
  89. "vue": {
  90. root: "Vue",
  91. commonjs: "vue",
  92. commonjs2: "vue",
  93. amd: "vue"
  94. }
  95. },
  96. output: {
  97. // 把子应用打包成 umd 库格式
  98. library: `${name}-[name]`,
  99. libraryTarget: "umd",
  100. jsonpFunction: `webpackJsonp_${name}`
  101. },
  102. resolve: {
  103. alias: {
  104. "@": resolve("src")
  105. }
  106. },
  107. plugins: [
  108. new loadSdkPlugin({ sdkPath: "sdk", jsonPath: "sdk" })
  109. // new injectSdks({path: path.resolve(`dist/${name}`),sdkName:name}),
  110. // new createTisplatformPlugin({path: path.resolve(`dist/${name}`),sdkName:name})
  111. ],
  112. },
  113. css:{
  114. loaderOptions:{
  115. postcss:{
  116. plugins:[
  117. pxtoviewport({
  118. // options
  119. unitToConvert: 'px',//(String) 需要转换的单位,默认为"px"
  120. viewportWidth: 1920, // (Number) 设计稿的视口宽度 pc 1600 pad/pc 1920 mobile 3120
  121. unitPrecision: 3, // (Number) 单位转换后保留的精度(很多时候无法整除)
  122. viewportUnit: 'vw', // (String) 希望使用的视口单位
  123. selectorBlackList: ['.ignore', '.hairlines', 'LoginPage'],
  124. /*(Array) CSS使px
  125. 如果传入的值为字符串的话只要选择器中含有传入值就会被匹配
  126. 例如 selectorBlackList ['body'] 的话 那么 .body-class 就会被忽略
  127. 如果传入的值为正则表达式的话那么就会依据CSS选择器是否匹配该正则
  128. 例如 selectorBlackList [/^body$/] , 那么 body 会被忽略 .body 不会*/
  129. minPixelValue: 8, // (Number) 设置最小的转换数值,如果为1的话,只有大于1的值会被转换
  130. mediaQuery: false, // (Boolean) 媒体查询里的单位是否需要转换单位
  131. exclude: [/^node_modules$/,/Mobile/,/LoginPagePc\.vue$/],// (Array or Regexp) 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件
  132. // include: /\/src\/mobile\//,
  133. /*(Array or Regexp) include 'src/mobile'
  134. 如果值是一个正则表达式将包含匹配的文件否则将排除该文件
  135. 如果传入的值是一个数组那么数组里的值必须为正则
  136. 注意exclude和include是可以一起设置的将取两者规则的交集*/
  137. landscapeUnit: 'vw', //(String)横屏时使用的单位
  138. landscapeWidth: 3120 //(Number)横屏时使用的视口宽度
  139. }),
  140. pxtoviewport({
  141. // options
  142. unitToConvert: 'px',//(String) 需要转换的单位,默认为"px"
  143. viewportWidth: 1560, // (Number) 设计稿的视口宽度 pc 1600 pad/pc 1920 mobile 3120
  144. unitPrecision: 3, // (Number) 单位转换后保留的精度(很多时候无法整除)
  145. viewportUnit: 'vw', // (String) 希望使用的视口单位
  146. selectorBlackList: ['.ignore', '.hairlines', 'LoginPage'],
  147. /*(Array) CSS使px
  148. 如果传入的值为字符串的话只要选择器中含有传入值就会被匹配
  149. 例如 selectorBlackList ['body'] 的话 那么 .body-class 就会被忽略
  150. 如果传入的值为正则表达式的话那么就会依据CSS选择器是否匹配该正则
  151. 例如 selectorBlackList [/^body$/] , 那么 body 会被忽略 .body 不会*/
  152. minPixelValue: 8, // (Number) 设置最小的转换数值,如果为1的话,只有大于1的值会被转换
  153. mediaQuery: false, // (Boolean) 媒体查询里的单位是否需要转换单位
  154. exclude: [/^node_modules$/],// (Array or Regexp) 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件
  155. include: /Mobile/,
  156. /*(Array or Regexp) include 'src/mobile'
  157. 如果值是一个正则表达式将包含匹配的文件否则将排除该文件
  158. 如果传入的值是一个数组那么数组里的值必须为正则
  159. 注意exclude和include是可以一起设置的将取两者规则的交集*/
  160. landscapeUnit: 'vw', //(String)横屏时使用的单位
  161. landscapeWidth: 3120 //(Number)横屏时使用的视口宽度
  162. })
  163. ]
  164. }
  165. }
  166. }
  167. };