Skip to content

Commit 4a8a3c5

Browse files
committed
Babel config to presets & update version & add compress.
1 parent 57d93e8 commit 4a8a3c5

11 files changed

+18568
-88
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 TANG
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+29-7
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@
1919
* [vue-virtual-scroll-list infinite data by increasing 20 each time](https://tangbc.github.io/vue-virtual-scroll-list/demo/infinite/).
2020

2121

22-
## Usage
22+
## Example
2323

24-
Using by npm:
24+
#### Using by npm:
2525

2626
```
2727
npm install vue-virtual-scroll-list --save
2828
```
2929

30-
31-
## Example
32-
33-
Using Vue single file components:
34-
3530
```javascript
3631
<template>
3732
<div>
@@ -61,6 +56,33 @@ Using Vue single file components:
6156

6257
The `<Item />` component is defined outside but included inside the `<VirtualList />` component. `VirtualList` has nothing to do with `<Item />`, so you can use virtual list with any list item component your project need, you just want to care about component `<Item />` and data `items`.
6358

59+
#### Using by script tag:
60+
61+
```html
62+
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
63+
<script src="https://tangbc.github.io/vue-virtual-scroll-list/dist/vue-virtual-scroll-list.js"></script>
64+
65+
<div id="app">
66+
<virtual-list :size="40" :remain="8">
67+
<div class="item" v-for="(item, index) of items" :key="index">Item: # {{ index }}</div>
68+
</virtual-list>
69+
</div>
70+
```
71+
72+
```javascript
73+
new Vue({
74+
el: '#app',
75+
data: {
76+
items: new Array(10000)
77+
},
78+
components: {
79+
'virtual-list': VirutalList
80+
}
81+
});
82+
```
83+
84+
**Notice: list Item component or frag using `v-for` must designate the `:key` property.**
85+
6486

6587
## Support props type
6688

demo/build/finite.js

+9,230-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/build/finite.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/build/infinite.js

+9,230-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/build/infinite.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-virtual-scroll-list.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-virtual-scroll-list.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
22
"name": "vue-virtual-scroll-list",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A vue component support big data by using virtual scroll list. Tiny, smooth and without any dependence.",
5-
"main": "src/index.js",
5+
"main": "dist/vue-virtual-scroll-list.js",
6+
"files": [
7+
"dist/vue-virtual-scroll-list.js"
8+
],
69
"scripts": {
7-
"demo": "webpack --watch --config webpack.config.js"
10+
"build": "cross-env NODE_ENV=production webpack --config webpack.config.js",
11+
"demo": "cross-env NODE_ENV=development webpack --watch --config webpack.config.js"
812
},
913
"keywords": [
1014
"vue",

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
117117
}
118118
});
119119

120-
export default VirtualList;
120+
module.exports = VirtualList;

webpack.config.js

+45-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require('path');
22
var webpack = require('webpack');
33

4-
module.exports = {
4+
var config = {
55
entry: {
66
finite: './demo/finite/index.js',
77
infinite: './demo/infinite/index.js'
@@ -23,15 +23,57 @@ module.exports = {
2323
{
2424
test: /.js$/,
2525
loader: 'babel-loader',
26-
exclude: /node_modules/
26+
exclude: /node_modules/,
27+
query: {
28+
presets: ['es2015']
29+
}
2730
}
2831
]
2932
},
3033
resolve: {
3134
alias: {
32-
'vue': 'vue/dist/vue.min.js',
35+
'vue$': 'vue/dist/vue.js',
3336
'virtual-list': path.resolve(__dirname, './src')
3437
}
3538
},
3639
devtool: '#source-map'
3740
};
41+
42+
if (process.env.NODE_ENV === 'production') {
43+
config.entry = './src/index';
44+
45+
config.output = {
46+
path: 'dist',
47+
libraryTarget: 'umd',
48+
library: 'VirutalList',
49+
filename: 'vue-virtual-scroll-list.js'
50+
};
51+
52+
config.externals = {
53+
vue: {
54+
amd: 'vue',
55+
root: 'Vue',
56+
commonjs: 'vue',
57+
commonjs2: 'vue'
58+
}
59+
}
60+
61+
config.plugins = [
62+
new webpack.DefinePlugin({
63+
'process.env': {
64+
NODE_ENV: '"production"'
65+
}
66+
}),
67+
new webpack.optimize.UglifyJsPlugin({
68+
sourceMap: true,
69+
compress: {
70+
warnings: false
71+
}
72+
}),
73+
new webpack.LoaderOptionsPlugin({
74+
minimize: true
75+
})
76+
];
77+
}
78+
79+
module.exports = config;

0 commit comments

Comments
 (0)