Skip to content

Commit c4bf077

Browse files
committed
support umd
1 parent 5a55adc commit c4bf077

File tree

9 files changed

+7751
-1788
lines changed

9 files changed

+7751
-1788
lines changed

.babelrc

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
{
33
"presets": [
44
["env", {
5-
"modules": "commonjs",
5+
"modules": false,
6+
"loose": true,
67
"targets": {
78
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
89
}
910
}],
1011
"stage-2"
1112
],
1213
"plugins": [
13-
"transform-runtime"
14+
"transform-object-assign"
1415
]
1516
}

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ See https://ibufu.github.io/vue2-scrollspy/
1010

1111
## Installation
1212

13+
### NPM
1314
```
1415
$ npm install vue2-scrollspy --save
1516
```
1617

18+
### CDN
19+
```html
20+
<script src="unpkg.com/vue2-scrollspy/dist/index.js"></script>
21+
```
22+
1723
## Basic Usage
1824
```js
1925
import Vue from 'vue';

build/webpack.config.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const path = require('path')
2+
const webpackConfig = {
3+
entry: {
4+
'vue2-scrollspy': './src/index.js'
5+
},
6+
mode: 'production',
7+
output: {
8+
filename: 'index.js',
9+
path: path.join(__dirname, '../dist'),
10+
library: 'ScrollSpy',
11+
libraryTarget: 'umd'
12+
},
13+
module: {
14+
rules: [
15+
{
16+
enforce: 'pre',
17+
test: /\.js$/,
18+
exclude: /node_modules/,
19+
loader: 'eslint-loader'
20+
},
21+
{
22+
test: /\.js$/,
23+
loader: 'babel-loader',
24+
exclude: /node_modules/
25+
}
26+
]
27+
},
28+
plugins: []
29+
}
30+
31+
if (process.env.npm_config_report) {
32+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
33+
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
34+
}
35+
36+
module.exports = webpackConfig

docs-src/src/demo.vue

+75-73
Large diffs are not rendered by default.

docs-src/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue'
22
import demo from './demo.vue'
3-
import scrollSpy, { Easing } from '../../src/index'
3+
import scrollSpy, { Easing } from '../../dist/index'
44

55
Vue.use(scrollSpy, {
66
easing: Easing.Cubic.In

docs-src/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
'babel-loader',
2727
'eslint-loader'
2828
],
29-
exclude: /node_modules/
29+
exclude: /node_modules|dist/
3030
}
3131
]
3232
}

0 commit comments

Comments
 (0)