Skip to content

Commit 23cb34c

Browse files
committed
update: add '__VERSION__';
1 parent f13afd1 commit 23cb34c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ import css from './css/index.styl';
55

66
polyfill();
77

8+
/* eslint no-undef:0 */
9+
ImageViewer.version = __VERSION__;
10+
811
export default ImageViewer;

webpack.config.base.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
const fs = require('fs');
12
const path = require('path');
3+
const webpack = require('webpack');
4+
5+
const getVersion = () => {
6+
const json = JSON.parse(fs.readFileSync('./package.json').toString());
7+
return json.version;
8+
};
29

310
const config = {
411
entry: {
@@ -72,7 +79,11 @@ const config = {
7279
}
7380
]
7481
},
75-
plugins: []
82+
plugins: [
83+
new webpack.DefinePlugin({
84+
__VERSION__: JSON.stringify(getVersion())
85+
})
86+
]
7687
};
7788

7889
module.exports = config;

0 commit comments

Comments
 (0)