babel.config.js 1.1 KB

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