element/build/config.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

var path = require('path');
var fs = require('fs');
2016-11-13 22:08:38 +08:00
var nodeExternals = require('webpack-node-externals');
var Components = require('../components.json');
var saladConfig = require('../packages/theme-default/salad.config.json');
var utilsList = fs.readdirSync(path.resolve(__dirname, '../src/utils'));
var mixinsList = fs.readdirSync(path.resolve(__dirname, '../src/mixins'));
var externals = {};
Object.keys(Components).forEach(function(key) {
2016-10-25 21:35:41 +08:00
externals[`element-ui/packages/${key}`] = `element-ui/lib/${key}`;
});
2016-10-17 17:47:24 +08:00
2016-11-13 22:08:38 +08:00
externals['element-ui/src/locale'] = 'element-ui/lib/locale';
utilsList.forEach(function(file) {
file = path.basename(file, '.js');
externals[`element-ui/src/utils/${file}`] = `element-ui/lib/utils/${file}`;
});
mixinsList.forEach(function(file) {
file = path.basename(file, '.js');
externals[`element-ui/src/mixins/${file}`] = `element-ui/lib/mixins/${file}`;
});
2016-11-13 22:08:38 +08:00
externals = [Object.assign({
2016-10-17 17:47:24 +08:00
vue: 'vue'
2016-11-13 22:08:38 +08:00
}, externals), nodeExternals()];
exports.externals = externals;
exports.alias = {
main: path.resolve(__dirname, '../src'),
packages: path.resolve(__dirname, '../packages'),
2016-10-13 11:12:24 +08:00
examples: path.resolve(__dirname, '../examples'),
'element-ui': path.resolve(__dirname, '../')
};
2016-10-17 17:47:24 +08:00
exports.vue = {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
};
exports.jsexclude = /node_modules|utils\/popper\.js|utils\/date.\js/;
2016-10-11 19:00:37 +08:00
exports.postcss = function(webapck) {
2016-11-13 22:08:38 +08:00
saladConfig.features.partialImport = {
addDependencyTo: webapck
};
2016-10-11 19:00:37 +08:00
return [
2016-11-13 22:08:38 +08:00
require('postcss-salad')(saladConfig)
2016-10-11 19:00:37 +08:00
];
};