config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var path = require('path');
  2. var fs = require('fs');
  3. var nodeExternals = require('webpack-node-externals');
  4. var Components = require('../components.json');
  5. var utilsList = fs.readdirSync(path.resolve(__dirname, '../src/utils'));
  6. var mixinsList = fs.readdirSync(path.resolve(__dirname, '../src/mixins'));
  7. var transitionList = fs.readdirSync(path.resolve(__dirname, '../src/transitions'));
  8. var externals = {};
  9. Object.keys(Components).forEach(function(key) {
  10. externals[`element-ui/packages/${key}`] = `element-ui/lib/${key}`;
  11. });
  12. externals['element-ui/src/locale'] = 'element-ui/lib/locale';
  13. utilsList.forEach(function(file) {
  14. file = path.basename(file, '.js');
  15. externals[`element-ui/src/utils/${file}`] = `element-ui/lib/utils/${file}`;
  16. });
  17. mixinsList.forEach(function(file) {
  18. file = path.basename(file, '.js');
  19. externals[`element-ui/src/mixins/${file}`] = `element-ui/lib/mixins/${file}`;
  20. });
  21. transitionList.forEach(function(file) {
  22. file = path.basename(file, '.js');
  23. externals[`element-ui/src/transitions/${file}`] = `element-ui/lib/transitions/${file}`;
  24. });
  25. externals = [Object.assign({
  26. vue: 'vue'
  27. }, externals), nodeExternals()];
  28. exports.externals = externals;
  29. exports.alias = {
  30. main: path.resolve(__dirname, '../src'),
  31. packages: path.resolve(__dirname, '../packages'),
  32. examples: path.resolve(__dirname, '../examples'),
  33. 'element-ui': path.resolve(__dirname, '../')
  34. };
  35. exports.vue = {
  36. root: 'Vue',
  37. commonjs: 'vue',
  38. commonjs2: 'vue',
  39. amd: 'vue'
  40. };
  41. exports.jsexclude = /node_modules|utils\/popper\.js|utils\/date\.js/;