Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dependency and build fix #246

Merged
merged 3 commits into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"presets": [
["@babel/preset-env", {
"modules": false,
"targets": {
"browsers": [
"last 2 versions"
]
}
}],
"@babel/stage-2"
],
"comments": false
}
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,14 @@ Simply run `yarn add vue-chartjs chart.js`
Or if you want to use it directly in the browser add

```html
<script src="https://unpkg.com/vue-chartjs/dist/vue-chartjs.full.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
<script src="https://unpkg.com/vue-chartjs/dist/vue-chartjs.min.js"></script>
```
to your scripts. See [Codepen](https://codepen.io/apertureless/pen/zEvvWM)

## Explanation of Different Builds
There are three different entry points. It depends on which build setup do you have. The dependencies are bundled or required as a peerDependency.

- Browser
- Browserify / Webpack 1
- Webpack 2

| Build | Chart.js |
|---|---|
| vue-chartjs.full.js | Bundled |
| vue-chartjs.full.min.js | Bundled |
| vue-chartjs.js | peerDependency |
| vue-chartjs.min.js | peerDependency |
| es/index* | peerDependency |

### Browser
You can use `vue-chartjs` directly in the browser without any build setup. Like in this [codepen](https://codepen.io/apertureless/pen/zEvvWM). For this case, please use the `vue-chartjs.full.min.js` which is the minified version. It has Chart.js bundled into it. And bundled to a UMD Module. So you only need that one file.
You can use `vue-chartjs` directly in the browser without any build setup. Like in this [codepen](https://codepen.io/apertureless/pen/zEvvWM). For this case, please use the `vue-chartjs.min.js` which is the minified version. You also need to add the Chart.js CDN script.

You can then simply register your component:

Expand Down
92 changes: 0 additions & 92 deletions build/webpack.release.full.js

This file was deleted.

17 changes: 0 additions & 17 deletions build/webpack.release.full.min.js

This file was deleted.

10 changes: 8 additions & 2 deletions build/webpack.release.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ module.exports = {
umdNamedDefine: true
},
externals: {
'chart.js': 'chart.js'
'chart.js': {
root: 'Chart',
commonjs: 'chart.js',
commonjs2: 'chart.js',
amd: 'chart.js'
}
},
resolve: {
extensions: ['.js', '.vue', '.json'],
Expand Down Expand Up @@ -71,7 +76,8 @@ module.exports = {
]
},
plugins: [
new webpack.BannerPlugin(banner)
new webpack.BannerPlugin(banner),
new webpack.optimize.ModuleConcatenationPlugin()
]
}

Expand Down
1 change: 1 addition & 0 deletions build/webpack.release.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
delete config.devtool

config.plugins = [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
Expand Down
Loading