v-page 2.0.9 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -93
- package/dist/v-page.js +1 -1
- package/dist/v-page.js.map +1 -1
- package/package.json +72 -65
- package/types/index.d.ts +62 -0
- package/.babelrc +0 -6
- package/.circleci/config.yml +0 -40
- package/.editorconfig +0 -9
- package/src/Page.js +0 -214
- package/src/index.js +0 -32
- package/src/language.js +0 -34
- package/src/page.sass +0 -116
- package/tests/unit/setup.js +0 -8
- package/tests/unit/v-page.spec.js +0 -49
- package/webpack.config.js +0 -118
package/src/Page.js
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import './page.sass'
|
|
2
|
-
import languages from './language'
|
|
3
|
-
|
|
4
|
-
const FIRST = 1
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
name: 'v-page',
|
|
8
|
-
props: {
|
|
9
|
-
value: {
|
|
10
|
-
type: Number,
|
|
11
|
-
default: 0
|
|
12
|
-
},
|
|
13
|
-
totalRow: {
|
|
14
|
-
type: Number,
|
|
15
|
-
default: 0
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* page size list
|
|
19
|
-
* false: close page size menu bar
|
|
20
|
-
* array: custom page sizes menu
|
|
21
|
-
*/
|
|
22
|
-
pageSizeMenu: {
|
|
23
|
-
type: [Boolean, Array],
|
|
24
|
-
default: function () {
|
|
25
|
-
return [10, 20, 50, 100]
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
language: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: 'cn'
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* pagination alignment direction
|
|
34
|
-
* 'left'
|
|
35
|
-
* 'center'
|
|
36
|
-
* 'right'(default)
|
|
37
|
-
*/
|
|
38
|
-
align: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: 'right'
|
|
41
|
-
},
|
|
42
|
-
disabled: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
default: false
|
|
45
|
-
},
|
|
46
|
-
border: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
default: true
|
|
49
|
-
},
|
|
50
|
-
info: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: true
|
|
53
|
-
},
|
|
54
|
-
pageNumber: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: true
|
|
57
|
-
},
|
|
58
|
-
/**
|
|
59
|
-
* first page button
|
|
60
|
-
*/
|
|
61
|
-
first: {
|
|
62
|
-
type: Boolean,
|
|
63
|
-
default: true
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* last page button
|
|
67
|
-
*/
|
|
68
|
-
last: {
|
|
69
|
-
type: Boolean,
|
|
70
|
-
default: true
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
data () {
|
|
74
|
-
return {
|
|
75
|
-
pageSize: this.pageSizeMenu === false ? 10 : this.pageSizeMenu[0],
|
|
76
|
-
lastPageSize: -1,
|
|
77
|
-
current: 0,
|
|
78
|
-
pageNumberSize: 5,
|
|
79
|
-
i18n: languages[this.language] || languages.cn
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
computed: {
|
|
83
|
-
totalPage () {
|
|
84
|
-
return Math.ceil(this.totalRow / this.pageSize)
|
|
85
|
-
},
|
|
86
|
-
pageNumbers () {
|
|
87
|
-
const { current, pageNumberSize, totalPage } = this
|
|
88
|
-
const half = Math.floor(pageNumberSize / 2)
|
|
89
|
-
const start = current - half
|
|
90
|
-
return Array.apply(null, { length: pageNumberSize })
|
|
91
|
-
.map((val, index) => start + index)
|
|
92
|
-
.filter(val => val > 0 && val <= totalPage)
|
|
93
|
-
},
|
|
94
|
-
pageInfo () {
|
|
95
|
-
return this.i18n.pageInfo
|
|
96
|
-
.replace('#pageNumber#', this.current)
|
|
97
|
-
.replace('#totalPage#', this.totalPage)
|
|
98
|
-
.replace('#totalRow#', this.totalRow)
|
|
99
|
-
},
|
|
100
|
-
classes () {
|
|
101
|
-
return {
|
|
102
|
-
'v-pagination--no-border': !this.border,
|
|
103
|
-
'v-pagination--right': this.align === 'right',
|
|
104
|
-
'v-pagination--center': this.align === 'center',
|
|
105
|
-
'v-pagination--disabled': this.disabled
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
isFirst () {
|
|
109
|
-
return this.current === FIRST
|
|
110
|
-
},
|
|
111
|
-
isLast () {
|
|
112
|
-
return this.current === this.totalPage
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
watch: {
|
|
116
|
-
value (val) {
|
|
117
|
-
if (typeof val === 'number' && val > 0) this.goPage(val, false)
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
render (h) {
|
|
121
|
-
const items = []
|
|
122
|
-
// page length list
|
|
123
|
-
if (Array.isArray(this.pageSizeMenu) && this.pageSizeMenu.length) {
|
|
124
|
-
items.push(h('li', { class: 'v-pagination__list' }, [h('a', [
|
|
125
|
-
h('span', this.i18n.pageLength),
|
|
126
|
-
h('select', {
|
|
127
|
-
attrs: { disabled: this.disabled },
|
|
128
|
-
on: {
|
|
129
|
-
change: e => {
|
|
130
|
-
if (e.srcElement && e.srcElement.value) {
|
|
131
|
-
this.pageSize = Number(e.srcElement.value)
|
|
132
|
-
}
|
|
133
|
-
this.goPage()
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}, this.pageSizeMenu.map(val => {
|
|
137
|
-
return h('option', { attrs: { value: val } }, val)
|
|
138
|
-
}))
|
|
139
|
-
])]))
|
|
140
|
-
}
|
|
141
|
-
// page info
|
|
142
|
-
if (this.info) {
|
|
143
|
-
items.push(h('li', { class: 'v-pagination__info' }, [h('a', this.pageInfo)]))
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* page number generator
|
|
147
|
-
* @param classes
|
|
148
|
-
* @param num
|
|
149
|
-
* @param text
|
|
150
|
-
* @return VNode
|
|
151
|
-
*/
|
|
152
|
-
const genItem = (classes, num, text) => {
|
|
153
|
-
return h('li', { class: classes }, [
|
|
154
|
-
h('a', {
|
|
155
|
-
attrs: { href: 'javascript:void(0)' },
|
|
156
|
-
on: { click: () => this.goPage(num) }
|
|
157
|
-
}, text)
|
|
158
|
-
])
|
|
159
|
-
}
|
|
160
|
-
// first
|
|
161
|
-
if (this.first) {
|
|
162
|
-
items.push(genItem({ disabled: this.isFirst }, FIRST, this.i18n.first))
|
|
163
|
-
}
|
|
164
|
-
// previous
|
|
165
|
-
items.push(genItem({ disabled: this.isFirst }, this.current - 1, this.i18n.previous))
|
|
166
|
-
// page numbers
|
|
167
|
-
if (this.pageNumber) {
|
|
168
|
-
items.push(...this.pageNumbers.map(val => genItem({
|
|
169
|
-
active: val === this.current
|
|
170
|
-
}, val, val)))
|
|
171
|
-
}
|
|
172
|
-
// next
|
|
173
|
-
items.push(genItem({ disabled: this.isLast }, this.current + 1, this.i18n.next))
|
|
174
|
-
// last
|
|
175
|
-
if (this.last) {
|
|
176
|
-
items.push(genItem({ disabled: this.isLast }, this.totalPage, this.i18n.last))
|
|
177
|
-
}
|
|
178
|
-
return h('div', {
|
|
179
|
-
class: {
|
|
180
|
-
'v-pagination': true,
|
|
181
|
-
...this.classes
|
|
182
|
-
}
|
|
183
|
-
}, [h('ul', items)])
|
|
184
|
-
},
|
|
185
|
-
methods: {
|
|
186
|
-
goPage (pNum = FIRST, respond = true) {
|
|
187
|
-
if (this.disabled) return
|
|
188
|
-
if (typeof pNum !== 'number') return
|
|
189
|
-
let num = pNum < FIRST ? FIRST : pNum
|
|
190
|
-
if (pNum > this.totalPage && this.totalPage > 0) num = this.totalPage
|
|
191
|
-
|
|
192
|
-
// exit when duplicate operation
|
|
193
|
-
if (num === this.current && this.pageSize === this.lastPageSize) return
|
|
194
|
-
|
|
195
|
-
this.current = num
|
|
196
|
-
// update v-model value
|
|
197
|
-
if (respond) this.$emit('input', this.current)
|
|
198
|
-
this.lastPageSize = this.pageSize
|
|
199
|
-
this.change()
|
|
200
|
-
},
|
|
201
|
-
reload () {
|
|
202
|
-
this.change()
|
|
203
|
-
},
|
|
204
|
-
change () {
|
|
205
|
-
this.$emit('page-change', {
|
|
206
|
-
pageNumber: this.current,
|
|
207
|
-
pageSize: Number(this.pageSize)
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
mounted () {
|
|
212
|
-
this.goPage(this.value ? this.value : FIRST)
|
|
213
|
-
}
|
|
214
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Page from './Page'
|
|
2
|
-
|
|
3
|
-
const Plugin = {
|
|
4
|
-
install (Vue, options = {}) {
|
|
5
|
-
if (Object.keys(options).length) {
|
|
6
|
-
const props = Page.props
|
|
7
|
-
const {
|
|
8
|
-
language,
|
|
9
|
-
align,
|
|
10
|
-
info,
|
|
11
|
-
border,
|
|
12
|
-
pageNumber,
|
|
13
|
-
first,
|
|
14
|
-
last,
|
|
15
|
-
pageSizeMenu
|
|
16
|
-
} = options
|
|
17
|
-
|
|
18
|
-
if (language) props.language.default = language
|
|
19
|
-
if (align) props.align.default = align
|
|
20
|
-
if (typeof info === 'boolean') props.info.default = info
|
|
21
|
-
if (typeof border === 'boolean') props.border.default = border
|
|
22
|
-
if (typeof pageNumber === 'boolean') props.pageNumber.default = pageNumber
|
|
23
|
-
if (typeof first === 'boolean') props.first.default = first
|
|
24
|
-
if (typeof last === 'boolean') props.last.default = last
|
|
25
|
-
if (typeof pageSizeMenu !== 'undefined') props.pageSizeMenu.default = pageSizeMenu
|
|
26
|
-
}
|
|
27
|
-
Vue.component(Page.name, Page)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { Page }
|
|
32
|
-
export default Plugin
|
package/src/language.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
cn: {
|
|
3
|
-
pageLength: '每页记录数 ',
|
|
4
|
-
pageInfo: '当前显示第 #pageNumber# / #totalPage# 页(共#totalRow#条记录)',
|
|
5
|
-
first: '首页',
|
|
6
|
-
previous: '«',
|
|
7
|
-
next: '»',
|
|
8
|
-
last: '尾页'
|
|
9
|
-
},
|
|
10
|
-
en: {
|
|
11
|
-
pageLength: 'Page length ',
|
|
12
|
-
pageInfo: 'Current #pageNumber# / #totalPage# (total #totalRow# records)',
|
|
13
|
-
first: 'First',
|
|
14
|
-
previous: '«',
|
|
15
|
-
next: '»',
|
|
16
|
-
last: 'Last'
|
|
17
|
-
},
|
|
18
|
-
de: {
|
|
19
|
-
pageLength: 'Seitenlänge ',
|
|
20
|
-
pageInfo: 'Aktuell #pageNumber# / #totalPage# (gesamt #totalRow# Aufzeichnungen)',
|
|
21
|
-
first: 'Zuerst',
|
|
22
|
-
previous: '«',
|
|
23
|
-
next: '»',
|
|
24
|
-
last: 'Letzte'
|
|
25
|
-
},
|
|
26
|
-
jp: {
|
|
27
|
-
pageLength: 'ページごとの記録数',
|
|
28
|
-
pageInfo: '現在の第 #pageNumber# / #totalPage# ページ(全部で #totalRow# 条の記録)',
|
|
29
|
-
first: 'トップページ',
|
|
30
|
-
previous: '«',
|
|
31
|
-
next: '»',
|
|
32
|
-
last: '尾のページ'
|
|
33
|
-
}
|
|
34
|
-
}
|
package/src/page.sass
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
$borderRadius: 2px
|
|
2
|
-
|
|
3
|
-
@mixin disabled
|
|
4
|
-
color: #999
|
|
5
|
-
cursor: default
|
|
6
|
-
&:hover
|
|
7
|
-
color: #999
|
|
8
|
-
background-color: white
|
|
9
|
-
box-shadow: none
|
|
10
|
-
z-index: auto
|
|
11
|
-
|
|
12
|
-
@mixin vendor-prefix($name, $value)
|
|
13
|
-
@each $vendor in ('-webkit-', '-moz-', '-ms-', '-o-', '')
|
|
14
|
-
#{$vendor}#{$name}: #{$value}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
div.v-pagination
|
|
18
|
-
margin: 0
|
|
19
|
-
display: block
|
|
20
|
-
|
|
21
|
-
&.v-pagination--right
|
|
22
|
-
text-align: right
|
|
23
|
-
&.v-pagination--center
|
|
24
|
-
text-align: center
|
|
25
|
-
&.v-pagination--disabled
|
|
26
|
-
li
|
|
27
|
-
a
|
|
28
|
-
@include disabled
|
|
29
|
-
&.active a
|
|
30
|
-
background-color: #f6f6f6
|
|
31
|
-
|
|
32
|
-
& > ul
|
|
33
|
-
display: inline-block
|
|
34
|
-
list-style: none
|
|
35
|
-
margin: 0
|
|
36
|
-
padding: 0
|
|
37
|
-
@include vendor-prefix('box-shadow', 0 1px 2px rgba(0, 0, 0, 0.05))
|
|
38
|
-
|
|
39
|
-
& > li
|
|
40
|
-
text-align: center
|
|
41
|
-
margin: 0
|
|
42
|
-
display: inline
|
|
43
|
-
|
|
44
|
-
& > a
|
|
45
|
-
margin: 0 0 0 -1px
|
|
46
|
-
position: relative
|
|
47
|
-
border: 1px solid #DEE2E6
|
|
48
|
-
padding: 6px 12px
|
|
49
|
-
line-height: 1.43
|
|
50
|
-
box-shadow: none
|
|
51
|
-
background-color: white
|
|
52
|
-
font-size: 14px
|
|
53
|
-
display: inline-block
|
|
54
|
-
text-decoration: none
|
|
55
|
-
color: #333
|
|
56
|
-
@include vendor-prefix('transition', all .5s cubic-bezier(.175, .885, .32, 1))
|
|
57
|
-
|
|
58
|
-
&:hover
|
|
59
|
-
z-index: 2
|
|
60
|
-
@include vendor-prefix('box-shadow', 0 0 8px rgba(0, 0, 0, 0.2))
|
|
61
|
-
|
|
62
|
-
&.disabled > a,
|
|
63
|
-
&.v-pagination__list > a,
|
|
64
|
-
&.v-pagination__info > a
|
|
65
|
-
@include disabled
|
|
66
|
-
|
|
67
|
-
&.active > a
|
|
68
|
-
cursor: default
|
|
69
|
-
color: #999
|
|
70
|
-
background-color: #eee
|
|
71
|
-
&:hover
|
|
72
|
-
box-shadow: none
|
|
73
|
-
z-index: auto
|
|
74
|
-
|
|
75
|
-
&:first-child > a
|
|
76
|
-
border-left-width: 1px
|
|
77
|
-
@include vendor-prefix('border-bottom-left-radius', $borderRadius)
|
|
78
|
-
@include vendor-prefix('border-top-left-radius', $borderRadius)
|
|
79
|
-
|
|
80
|
-
&:last-child > a
|
|
81
|
-
@include vendor-prefix('border-top-right-radius', $borderRadius)
|
|
82
|
-
@include vendor-prefix('border-bottom-right-radius', $borderRadius)
|
|
83
|
-
|
|
84
|
-
&.v-pagination__list
|
|
85
|
-
select
|
|
86
|
-
margin-left: 5px
|
|
87
|
-
width: auto !important
|
|
88
|
-
font-size: 12px
|
|
89
|
-
padding: 0
|
|
90
|
-
border: 1px solid #ccc
|
|
91
|
-
color: #333
|
|
92
|
-
outline: 0
|
|
93
|
-
&:hover
|
|
94
|
-
@include vendor-prefix('box-shadow', 0 0 2px rgba(0, 0, 0, 0.2))
|
|
95
|
-
|
|
96
|
-
&[disabled]
|
|
97
|
-
color: #999
|
|
98
|
-
|
|
99
|
-
&.v-pagination--no-border
|
|
100
|
-
& > ul
|
|
101
|
-
box-shadow: none
|
|
102
|
-
|
|
103
|
-
& > li
|
|
104
|
-
&:not(.active):not(.disabled):not(.v-pagination__info):not(.v-pagination__list) a:hover
|
|
105
|
-
box-shadow: none
|
|
106
|
-
z-index: auto
|
|
107
|
-
background-color: #ddd
|
|
108
|
-
|
|
109
|
-
&.active a
|
|
110
|
-
background-color: #f6f6f6
|
|
111
|
-
color: #aaa
|
|
112
|
-
|
|
113
|
-
& > a
|
|
114
|
-
border: 0
|
|
115
|
-
&:hover
|
|
116
|
-
z-index: auto
|
package/tests/unit/setup.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
require('jsdom-global')();
|
|
2
|
-
/**
|
|
3
|
-
* this line code is to fix 'TypeError: Super expression must either be null or a function' issues
|
|
4
|
-
* @link https://github.com/vuejs/vue-test-utils/issues/936
|
|
5
|
-
*/
|
|
6
|
-
window.Date = Date;
|
|
7
|
-
|
|
8
|
-
//global.expect = require('chai').expect;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils'
|
|
2
|
-
import page from '@/Page'
|
|
3
|
-
|
|
4
|
-
const expect = require('chai').expect
|
|
5
|
-
|
|
6
|
-
describe('v-page', function () {
|
|
7
|
-
describe('page-numbers', function () {
|
|
8
|
-
it('the page numbers should be [2,3,4,5,6] in page 4', function () {
|
|
9
|
-
const env = {
|
|
10
|
-
totalPage: 10,
|
|
11
|
-
pageNumberSize: 5,
|
|
12
|
-
current: 4
|
|
13
|
-
}
|
|
14
|
-
const values = page.computed.pageNumbers.call(env)
|
|
15
|
-
expect(values.sort().join('')).to.equal([2, 3, 4, 5, 6].sort().join(''))
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('dom operation test, click page number 5 item', () => {
|
|
20
|
-
const wapper = shallowMount(page, {
|
|
21
|
-
propsData: {
|
|
22
|
-
value: 3,
|
|
23
|
-
totalRow: 100
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('after click, the page 5 <li> item class name should be "active"', () => {
|
|
28
|
-
wapper.findAll('a').at(8).trigger('click')
|
|
29
|
-
// console.log(wapper.html());
|
|
30
|
-
// expect(wapper.props('totalRow')).to.equal(100);
|
|
31
|
-
// expect(wapper.is('div')).equal(true);
|
|
32
|
-
expect(wapper.findAll('li').at(6).classes('active')).to.equal(true)
|
|
33
|
-
})
|
|
34
|
-
it('the current page data should be 5', () => {
|
|
35
|
-
expect(wapper.vm.current).to.equal(5)
|
|
36
|
-
})
|
|
37
|
-
it('the page numbers should be [3,4,5,6,7]', () => {
|
|
38
|
-
expect(wapper.vm.pageNumbers.sort().join('')).to.equal([3, 4, 5, 6, 7].sort().join(''))
|
|
39
|
-
})
|
|
40
|
-
it('the current page should be 1 when change page size in list', () => {
|
|
41
|
-
// 设置下拉列表选择第三个项目(每页50条)
|
|
42
|
-
wapper.find('select').findAll('option').at(2).setSelected()
|
|
43
|
-
expect(wapper.vm.current).to.equal(1)
|
|
44
|
-
})
|
|
45
|
-
it('after page size change, the total pages should be 2', () => {
|
|
46
|
-
expect(wapper.vm.totalPage).to.equal(2)
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
})
|
package/webpack.config.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
var path = require('path')
|
|
2
|
-
var webpack = require('webpack')
|
|
3
|
-
var isCoverage = process.env.NODE_ENV === 'coverage';
|
|
4
|
-
module.exports = {
|
|
5
|
-
entry: './src/index.js',
|
|
6
|
-
output: {
|
|
7
|
-
path: path.resolve(__dirname, './dist'),
|
|
8
|
-
publicPath: '/dist/',
|
|
9
|
-
filename: 'v-page.js',
|
|
10
|
-
library: 'vPage',
|
|
11
|
-
libraryTarget: 'umd',
|
|
12
|
-
umdNamedDefine: true
|
|
13
|
-
},
|
|
14
|
-
module: {
|
|
15
|
-
rules: [
|
|
16
|
-
isCoverage ? {
|
|
17
|
-
test: /\.(js|ts)/,
|
|
18
|
-
include: path.resolve('src'), // instrument only testing sources with Istanbul, after ts-loader runs
|
|
19
|
-
loader: 'istanbul-instrumenter-loader'
|
|
20
|
-
} : {},
|
|
21
|
-
{
|
|
22
|
-
test: /\.css$/,
|
|
23
|
-
use: [
|
|
24
|
-
'vue-style-loader',
|
|
25
|
-
'css-loader'
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
test: /\.scss$/,
|
|
30
|
-
use: [
|
|
31
|
-
'vue-style-loader',
|
|
32
|
-
'css-loader',
|
|
33
|
-
'sass-loader'
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
test: /\.sass$/,
|
|
38
|
-
use: [
|
|
39
|
-
'vue-style-loader',
|
|
40
|
-
'css-loader',
|
|
41
|
-
'sass-loader?indentedSyntax'
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
test: /\.vue$/,
|
|
46
|
-
loader: 'vue-loader',
|
|
47
|
-
options: {
|
|
48
|
-
loaders: {
|
|
49
|
-
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
|
|
50
|
-
// the "scss" and "sass" values for the lang attribute to the right configs here.
|
|
51
|
-
// other preprocessors should work out of the box, no loader config like this necessary.
|
|
52
|
-
'scss': [
|
|
53
|
-
'vue-style-loader',
|
|
54
|
-
'css-loader',
|
|
55
|
-
'sass-loader'
|
|
56
|
-
],
|
|
57
|
-
'sass': [
|
|
58
|
-
'vue-style-loader',
|
|
59
|
-
'css-loader',
|
|
60
|
-
'sass-loader?indentedSyntax'
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
// other vue-loader options go here
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
test: /\.js$/,
|
|
68
|
-
loader: 'babel-loader',
|
|
69
|
-
exclude: /node_modules/
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
test: /\.(png|jpg|gif|svg)$/,
|
|
73
|
-
loader: 'file-loader',
|
|
74
|
-
options: {
|
|
75
|
-
name: '[name].[ext]?[hash]'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
resolve: {
|
|
81
|
-
alias: {
|
|
82
|
-
'vue$': 'vue/dist/vue.esm.js',
|
|
83
|
-
'@': path.resolve(__dirname, 'src/'),
|
|
84
|
-
'@test': path.resolve(__dirname, 'tests/')
|
|
85
|
-
},
|
|
86
|
-
extensions: ['*', '.js', '.vue', '.json']
|
|
87
|
-
},
|
|
88
|
-
devServer: {
|
|
89
|
-
historyApiFallback: true,
|
|
90
|
-
noInfo: true,
|
|
91
|
-
overlay: true
|
|
92
|
-
},
|
|
93
|
-
performance: {
|
|
94
|
-
hints: false
|
|
95
|
-
},
|
|
96
|
-
devtool: isCoverage?'inline-cheap-module-source-map':'#eval-source-map'
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (process.env.NODE_ENV === 'production') {
|
|
100
|
-
module.exports.devtool = '#source-map'
|
|
101
|
-
// http://vue-loader.vuejs.org/en/workflow/production.html
|
|
102
|
-
module.exports.plugins = (module.exports.plugins || []).concat([
|
|
103
|
-
new webpack.DefinePlugin({
|
|
104
|
-
'process.env': {
|
|
105
|
-
NODE_ENV: '"production"'
|
|
106
|
-
}
|
|
107
|
-
}),
|
|
108
|
-
new webpack.optimize.UglifyJsPlugin({
|
|
109
|
-
sourceMap: true,
|
|
110
|
-
compress: {
|
|
111
|
-
warnings: false
|
|
112
|
-
}
|
|
113
|
-
}),
|
|
114
|
-
new webpack.LoaderOptionsPlugin({
|
|
115
|
-
minimize: true
|
|
116
|
-
})
|
|
117
|
-
])
|
|
118
|
-
}
|