element/scripts/cooking.component.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-07-27 14:15:02 +08:00
var cooking = require('cooking');
var path = require('path');
var Components = require('../components.json');
2016-08-22 12:02:09 +08:00
var entries = {};
Object.keys(Components).forEach(function (key) {
const compo = Components[key];
compo[0] = path.join(process.cwd(), compo[0]);
entries[key] = compo;
});
2016-07-27 14:15:02 +08:00
cooking.set({
2016-08-22 12:02:09 +08:00
entry: entries,
2016-07-27 14:15:02 +08:00
dist: './lib',
2016-08-22 12:02:09 +08:00
clean: false,
format: 'cjs',
2016-07-27 14:15:02 +08:00
extractCSS: '[name]/style.css',
2016-09-06 11:51:08 +08:00
extends: ['vue2']
2016-07-27 14:15:02 +08:00
});
cooking.add('output.filename', '[name]/index.js');
cooking.add('resolve.alias', {
'main': path.join(__dirname, '../src'),
'packages': path.join(__dirname, '../packages'),
'examples': path.join(__dirname, '../examples')
});
var externals = {};
Object.keys(Components).forEach(function(key) {
2016-08-22 12:02:09 +08:00
externals[`packages/${key}/index.js`] = `element-ui/lib/${key}`;
externals[`packages/${key}/style.css`] = `element-ui/lib/${key}/style.css`;
externals['main/utils/clickoutside'] = 'element-ui/src/utils/clickoutside';
externals['main/utils/popper'] = 'element-ui/src/utils/popper';
externals['main/utils/vue-popper'] = 'element-ui/src/utils/vue-popper';
2016-07-27 14:15:02 +08:00
});
cooking.add('externals', Object.assign({
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
}, externals));
cooking.add('loader.js.exclude', /node_modules|utils\/popper\.js|util\/fecha.\js/);
module.exports = cooking.resolve();