Skip to content

Commit

Permalink
feat(webpack.config.base): Add GG_EDITOR_VERSION, G6_VERSION, G6_EDIT…
Browse files Browse the repository at this point in the history
…OR_VERSION from package.json as
  • Loading branch information
gaoli committed Sep 5, 2018
1 parent b8d0981 commit 2440d0d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion tools/webpack.config.base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const path = require('path');
const webpack = require('webpack');
const pkg = require('../package.json');

const rules = [{
test: /\.js$/,
Expand Down Expand Up @@ -30,12 +32,24 @@ const rules = [{
}],
}];

const plugins = [
new webpack.DefinePlugin({
GG_EDITOR_VERSION: JSON.stringify(pkg.version),
G6_VERSION: JSON.stringify(pkg.dependencies['@antv/g6']),
G6_EDITOR_VERSION: JSON.stringify(pkg.dependencies['@antv/g6-editor']),
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
];

const alias = {
// '@antv/g6$': '@antv/g6/src',
// '@antv/g6-editor$': '@antv/g6-editor/src',
'@utils': path.resolve(__dirname, '..', 'src/utils'),
'@common': path.resolve(__dirname, '..', 'src/common'),
'@components': path.resolve(__dirname, '..', 'src/components'),
'@helpers': path.resolve(__dirname, '..', 'src/helpers'),
'@utils': path.resolve(__dirname, '..', 'src/utils'),
};

const externals = {
Expand All @@ -57,6 +71,7 @@ module.exports = {
module: {
rules,
},
plugins,
resolve: {
alias,
},
Expand Down
2 changes: 1 addition & 1 deletion tools/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const output = {
};

module.exports = merge(baseConfig, {
entry,
devtool,
entry,
output,
});

0 comments on commit 2440d0d

Please sign in to comment.