Skip to content

Commit

Permalink
feat: tweak studio webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
zxc0328 committed Nov 18, 2019
1 parent e40926d commit f7a75f6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
6 changes: 3 additions & 3 deletions packages/graphin-studio/package.json
@@ -1,7 +1,7 @@
{
"name": "@antv/graphin-studio",
"version": "1.0.0",
"description": "an example for graphin",
"description": "An Example for Graphin",
"main": "dist/app.js",
"scripts": {
"start": " node --max_old_space_size=8192 ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot --env.NODE_ENV=development",
Expand Down Expand Up @@ -55,6 +55,6 @@
"example",
"graphene"
],
"author": "",
"license": "ISC"
"author": "Ant Financial",
"license": "MIT"
}
1 change: 1 addition & 0 deletions packages/graphin-studio/public/index.html
Expand Up @@ -17,6 +17,7 @@
crossorigin
src="https://gw.alipayobjects.com/os/lib/react-dom/16.12.0/umd/react-dom.production.min.js"
></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
<script crossorigin src="https://gw.alipayobjects.com/os/antv/pkg/_antv.g6-3.1.5/build/g6.js"></script>
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/antd/3.23.6/antd.min.js"></script>
Expand Down
49 changes: 39 additions & 10 deletions packages/graphin-studio/webpack.config.js
Expand Up @@ -10,7 +10,11 @@ module.exports = env => {
entry: {
bundle: './src/index.tsx',
},

optimization: {
splitChunks: {
chunks: 'all',
},
},
mode: env.NODE_ENV,
module: {
rules: [
Expand Down Expand Up @@ -105,16 +109,41 @@ module.exports = env => {
new HtmlWebpackPlugin({
title: 'example',
template: './public/index.html',
chunks: ['bundle'],
chunks: ['vendors~bundle', 'bundle'],
}),
],
externals: {
antd: 'window.antd',
'chinese-random-name': 'chineseRandomName',
lodash: '_',
react: 'window.React',
'react-dom': 'window.ReactDOM',
'@antv/g6': 'G6',
},
externals: [
{
antd: 'window.antd',
'chinese-random-name': 'chineseRandomName',
lodash: '_',
react: 'window.React',
'react-dom': 'window.ReactDOM',
'@antv/g6': 'G6',
},
// eslint-disable-next-line
(context, request, callback) => {
if (request === 'lodash') {
return callback(null, '_');
}
if (/lodash\//.test(request)) {
// lodash/isArray
const paths = request.split('/');
// lodash or lodash-es
paths[0] = '_';
// _.isArray
return callback(null, paths.join('.'));
}
if (/lodash\./.test(request)) {
// lodash.debounce
const paths = request.split('.');
// lodash or lodash-es
paths[0] = '_';
// _.debounce
return callback(null, paths.join('.'));
}
callback();
},
],
};
};
2 changes: 1 addition & 1 deletion packages/graphin/package.json
Expand Up @@ -32,7 +32,7 @@
"eventemitter3": "^4.0.0"
},
"sideEffects": false,
"author": "AntFinancial",
"author": "Ant Financial",
"license": "MIT",
"dependencies": {
"svg2marker": "^0.1.3",
Expand Down

0 comments on commit f7a75f6

Please sign in to comment.