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.

62 lines
1.4 KiB

3 years ago
  1. const plugins = []
  2. if (process.env.UNI_OPT_TREESHAKINGNG)
  3. plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
  4. if (
  5. (
  6. process.env.UNI_PLATFORM === 'app-plus' &&
  7. process.env.UNI_USING_V8
  8. ) ||
  9. (
  10. process.env.UNI_PLATFORM === 'h5' &&
  11. process.env.UNI_H5_BROWSER === 'builtin'
  12. )
  13. ) {
  14. const path = require('path')
  15. const isWin = /^win/.test(process.platform)
  16. const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
  17. const input = normalizePath(process.env.UNI_INPUT_DIR)
  18. try {
  19. plugins.push([
  20. require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
  21. {
  22. file(file) {
  23. file = normalizePath(file)
  24. if (file.indexOf(input) === 0)
  25. return path.relative(input, file)
  26. return false
  27. }
  28. }
  29. ])
  30. } catch (e) {}
  31. }
  32. process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
  33. process.UNI_LIBRARIES.forEach((libraryName) => {
  34. plugins.push([
  35. 'import',
  36. {
  37. libraryName: libraryName,
  38. customName: (name) => {
  39. return `${libraryName}/lib/${name}/${name}`
  40. }
  41. }
  42. ])
  43. })
  44. module.exports = {
  45. presets: [
  46. [
  47. '@vue/app',
  48. {
  49. modules: 'commonjs',
  50. useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
  51. }
  52. ]
  53. ],
  54. plugins
  55. }