g6/webpack.config.js

65 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-06-05 23:58:10 +08:00
const webpack = require('webpack');
const resolve = require('path').resolve;
const shelljs = require('shelljs');
const _ = require('lodash');
const entry = {
G6: './src/index.js',
G6Plugins: './plugins/index.js'
};
shelljs.ls(resolve(__dirname, 'plugins')).forEach(pluginPath => {
if (pluginPath !== 'index.js') {
2018-07-12 21:38:24 +08:00
const moduleName = 'plugin.' + pluginPath;
2018-06-05 23:58:10 +08:00
entry[moduleName] = `./plugins/${pluginPath}/index.js`;
2018-07-12 21:38:24 +08:00
} else {
const moduleName = 'plugins';
entry[moduleName] = './plugins/index.js';
2018-06-05 23:58:10 +08:00
}
});
module.exports = {
mode: 'production',
devtool: 'cheap-source-map',
entry,
output: {
filename: substitutions => `${_.lowerFirst(substitutions.chunk.name)}.js`,
library: '[name]',
libraryTarget: 'umd',
path: resolve(__dirname, 'build/')
},
externals: {
2018-07-12 21:38:24 +08:00
'@antv/g6': {
root: 'G6',
commonjs2: '@antv/g6',
commonjs: '@antv/g6',
amd: '@antv/g6'
}
2018-06-05 23:58:10 +08:00
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
2018-06-05 23:58:10 +08:00
use: {
loader: 'babel-loader',
options: {
babelrc: true
}
}
2018-07-22 18:02:53 +08:00
},
{
test: /\.worker.js$/,
2018-07-22 18:32:26 +08:00
loader: 'worker-loader',
options: {
inline: true
}
2018-06-05 23:58:10 +08:00
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.AggressiveMergingPlugin()
]
};