Skip to content

Commit

Permalink
Refactor: Don't include package.json into dist files
Browse files Browse the repository at this point in the history
Instead of including package.json file into the build files.
Use webpacks DefinePlugin to define a global lib version.
  • Loading branch information
nickknissen committed Feb 5, 2018
1 parent ebcab9f commit bdeac75
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ module.exports = {
'arrow-parens': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
},
"globals": {
"LIB_VERSION": true
}
}
9 changes: 8 additions & 1 deletion build/webpack.base.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict'
const webpack = require('webpack')
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
const npmCfg = require('../package.json')

function resolve (dir) {
return path.join(__dirname, '..', dir)
Expand Down Expand Up @@ -72,5 +74,10 @@ module.exports = {
}
}
]
}
},
plugins: [
new webpack.DefinePlugin({
LIB_VERSION: JSON.stringify(npmCfg.version)
})
]
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mixins from './mixins/index.js'
import npmCfg from '../package.json'

import {
Bar,
HorizontalBar,
Expand All @@ -13,7 +13,7 @@ import {
} from './BaseCharts'

const VueCharts = {
version: npmCfg.version,
version: LIB_VERSION,
Bar,
HorizontalBar,
Doughnut,
Expand Down

0 comments on commit bdeac75

Please sign in to comment.