project init
This commit is contained in:
commit
5e477ede8e
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/.env
|
||||
/.idea/
|
||||
/.wepycache/
|
||||
.wepycache
|
||||
|
||||
**/node_modules
|
||||
**/.DS_Store
|
||||
|
||||
/public
|
||||
/logs
|
||||
/build
|
||||
/dist
|
||||
/lib
|
||||
rev-manifest.json
|
||||
/yarn.lock
|
||||
/nohup.out
|
||||
/dist.tar.gz
|
||||
/config/apiclient_cert.p12
|
3
.prettierrc
Normal file
3
.prettierrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"singleQuote": true
|
||||
}
|
4
.wepyignore
Normal file
4
.wepyignore
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules
|
||||
dist
|
||||
.DS_Store
|
||||
*.wpy___jb_tmp___
|
1712
package-lock.json
generated
Normal file
1712
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
36
package.json
Normal file
36
package.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "gamemall",
|
||||
"version": "0.0.2",
|
||||
"description": "游戏电商小程序",
|
||||
"main": "dist/app.js",
|
||||
"scripts": {
|
||||
"dev": "wepy build --watch",
|
||||
"build": "cross-env NODE_ENV=production wepy build --no-cache",
|
||||
"dev:web": "wepy build --output web",
|
||||
"clean": "find ./dist -maxdepth 1 -not -name 'project.config.json' -not -name 'dist' | xargs rm -rf",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"wepy": {
|
||||
"module-a": false,
|
||||
"./src/components/list": "./src/components/wepy-list.wpy"
|
||||
},
|
||||
"author": "zhl <zhl010101@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"wepy": "^1.6.0",
|
||||
"wepy-async-function": "^1.4.4",
|
||||
"wepy-com-toast": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^7.2.1",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"babel-plugin-transform-export-extensions": "^6.22.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"cross-env": "^5.1.3",
|
||||
"less": "^3.8.1",
|
||||
"wepy-compiler-babel": "^1.5.1",
|
||||
"wepy-compiler-less": "^1.3.10"
|
||||
}
|
||||
}
|
16
project.config.json
Normal file
16
project.config.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"description": "游戏电商小程序",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": false,
|
||||
"postcss": false,
|
||||
"minified": false,
|
||||
"newFeature": true,
|
||||
"autoAudits": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"appid": "wxbf333d56b4de3905",
|
||||
"projectname": "gamemall",
|
||||
"miniprogramRoot": "dist/",
|
||||
"condition": {}
|
||||
}
|
69
src/app.wpy
Normal file
69
src/app.wpy
Normal file
@ -0,0 +1,69 @@
|
||||
<style lang="less">
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
import 'wepy-async-function'
|
||||
|
||||
|
||||
export default class extends wepy.app {
|
||||
config = {
|
||||
pages: [
|
||||
'pages/index'
|
||||
],
|
||||
window: {
|
||||
backgroundTextStyle: 'light',
|
||||
navigationBarBackgroundColor: '#fff',
|
||||
navigationBarTitleText: 'WeChat',
|
||||
navigationBarTextStyle: 'black'
|
||||
}
|
||||
}
|
||||
|
||||
globalData = {
|
||||
userInfo: null
|
||||
}
|
||||
|
||||
constructor () {
|
||||
super()
|
||||
this.use('requestfix')
|
||||
}
|
||||
|
||||
onLaunch() {
|
||||
this.testAsync()
|
||||
}
|
||||
|
||||
sleep (s) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve('promise resolved')
|
||||
}, s * 1000)
|
||||
})
|
||||
}
|
||||
|
||||
async testAsync () {
|
||||
const data = await this.sleep(3)
|
||||
console.log(data)
|
||||
}
|
||||
|
||||
getUserInfo(cb) {
|
||||
const that = this
|
||||
if (this.globalData.userInfo) {
|
||||
return this.globalData.userInfo
|
||||
}
|
||||
wepy.getUserInfo({
|
||||
success (res) {
|
||||
that.globalData.userInfo = res.userInfo
|
||||
cb && cb(res.userInfo)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
66
src/components/counter.wpy
Normal file
66
src/components/counter.wpy
Normal file
@ -0,0 +1,66 @@
|
||||
<style lang="less">
|
||||
.counter {
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
}
|
||||
.count {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
&.red {
|
||||
color: red;
|
||||
}
|
||||
&.green {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="counter {{style}}">
|
||||
<button @tap="plus" size="mini"> + </button>
|
||||
<button @tap="minus" size="mini"> - </button>
|
||||
<text class="count" :class="{red: num > 55, green: num < 45}"> {{num}} </text>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
|
||||
export default class Counter extends wepy.component {
|
||||
props = {
|
||||
num: {
|
||||
type: [Number, String],
|
||||
coerce: function (v) {
|
||||
return +v
|
||||
},
|
||||
default: 50
|
||||
}
|
||||
}
|
||||
|
||||
data = {
|
||||
}
|
||||
events = {
|
||||
'index-broadcast': (...args) => {
|
||||
let $event = args[args.length - 1]
|
||||
console.log(`${this.$name} receive ${$event.name} from ${$event.source.$name}`)
|
||||
}
|
||||
}
|
||||
|
||||
watch = {
|
||||
num (curVal, oldVal) {
|
||||
console.log(`旧值:${oldVal},新值:${curVal}`)
|
||||
}
|
||||
}
|
||||
|
||||
methods = {
|
||||
plus () {
|
||||
this.num = this.num + 1
|
||||
console.log(this.$name + ' plus tap')
|
||||
|
||||
this.$emit('index-emit', 1, 2, 3)
|
||||
},
|
||||
minus () {
|
||||
this.num = this.num - 1
|
||||
console.log(this.$name + ' minus tap')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
35
src/components/group.wpy
Normal file
35
src/components/group.wpy
Normal file
@ -0,0 +1,35 @@
|
||||
<style type="less">
|
||||
.group {}
|
||||
</style>
|
||||
<template>
|
||||
<view class="group">
|
||||
<text class="id">{{grouplist.id}}. </text>
|
||||
<text class="name" @tap="tap">{{grouplist.name}}</text>
|
||||
<view>
|
||||
<repeat for="{{grouplist.list}}" item="item">
|
||||
<groupitem :gitem="item"></groupitem>
|
||||
</repeat>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
import GroupItem from './groupitem'
|
||||
|
||||
export default class Group extends wepy.component {
|
||||
props = {
|
||||
grouplist: {},
|
||||
index: {}
|
||||
}
|
||||
|
||||
components = {
|
||||
groupitem: GroupItem
|
||||
}
|
||||
methods = {
|
||||
tap () {
|
||||
this.grouplist.name = `Parent Random(${Math.random()})`
|
||||
console.log(`Clicked Group ${this.$index}, ID is ${this.grouplist.id}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
27
src/components/groupitem.wpy
Normal file
27
src/components/groupitem.wpy
Normal file
@ -0,0 +1,27 @@
|
||||
<style type="less">
|
||||
.groupitem {
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="groupitem">
|
||||
--<text class="id">{{gitem.childid}}.</text>
|
||||
<text class="name" @tap="tap"> {{gitem.childname}}</text>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
|
||||
export default class GroupItem extends wepy.component {
|
||||
props = {
|
||||
gitem: {}
|
||||
}
|
||||
data = {
|
||||
}
|
||||
methods = {
|
||||
tap () {
|
||||
this.gitem.childname = `Child Random(${Math.random()})`
|
||||
console.log(`Clicked Group ${this.$parent.$index}. Item ${this.$index}, ID is ${this.gitem.childid}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
55
src/components/list.wpy
Normal file
55
src/components/list.wpy
Normal file
@ -0,0 +1,55 @@
|
||||
<style lang="less">
|
||||
.mylist:odd {
|
||||
color: red;
|
||||
}
|
||||
.mylist:even {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="list">
|
||||
<view>
|
||||
<button @tap="add" size="mini">添加列表</button>
|
||||
</view>
|
||||
<block wx:for-items="{{list}}" wx:for-index="index" wx:for-item="item" wx:key="id">
|
||||
<view @tap="tap" class="mylist">
|
||||
<text>{{item.id}}</text>: {{item.title}}
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
|
||||
export default class List extends wepy.component {
|
||||
data = {
|
||||
list: [
|
||||
{
|
||||
id: '0',
|
||||
title: 'loading'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
events = {
|
||||
'index-broadcast': (...args) => {
|
||||
let $event = args[args.length - 1]
|
||||
console.log(`${this.$name} receive ${$event.name} from ${$event.source.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
methods = {
|
||||
tap () {
|
||||
// this.num = this.num + 1
|
||||
console.log(this.$name + ' tap')
|
||||
},
|
||||
add () {
|
||||
let len = this.list.length
|
||||
this.list.push({id: len + 1, title: 'title_' + len})
|
||||
}
|
||||
}
|
||||
|
||||
onLoad () {
|
||||
}
|
||||
}
|
||||
</script>
|
43
src/components/panel.wpy
Normal file
43
src/components/panel.wpy
Normal file
@ -0,0 +1,43 @@
|
||||
<style lang="less">
|
||||
.panel {
|
||||
width: 100%;
|
||||
margin-top: 20rpx;
|
||||
text-align: left;
|
||||
font-size: 12px;
|
||||
padding-top: 20rpx;
|
||||
padding-left: 50rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border: 1px solid #ccc;
|
||||
|
||||
.title {
|
||||
padding-bottom: 20rpx;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.info {
|
||||
padding: 15rpx;
|
||||
}
|
||||
.testcounter {
|
||||
margin-top: 15rpx;
|
||||
position: absolute;
|
||||
}
|
||||
.counterview {
|
||||
margin-left: 120rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="panel">
|
||||
<slot name="title">
|
||||
Title
|
||||
</slot>
|
||||
<slot>
|
||||
</slot>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
|
||||
export default class Panel extends wepy.component {
|
||||
}
|
||||
</script>
|
55
src/components/wepy-list.wpy
Normal file
55
src/components/wepy-list.wpy
Normal file
@ -0,0 +1,55 @@
|
||||
<style lang="less">
|
||||
.mylist:odd {
|
||||
color: red;
|
||||
}
|
||||
.mylist:even {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="wepy-list">
|
||||
<view>
|
||||
<button @tap="add" size="mini">添加列表another</button>
|
||||
</view>
|
||||
<block wx:for-items="{{list}}" wx:for-index="index" wx:for-item="item" wx:key="id">
|
||||
<view @tap="tap" class="mylist">
|
||||
<text>{{item.id}}</text>: {{item.title}}
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
|
||||
export default class ListAnother extends wepy.component {
|
||||
data = {
|
||||
list: [
|
||||
{
|
||||
id: '0',
|
||||
title: 'loading'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
events = {
|
||||
'index-broadcast': (...args) => {
|
||||
let $event = args[args.length - 1]
|
||||
console.log(`${this.$name} receive ${$event.name} from ${$event.source.name}`)
|
||||
}
|
||||
}
|
||||
|
||||
methods = {
|
||||
tap () {
|
||||
// this.num = this.num + 1
|
||||
console.log(this.$name + ' tap')
|
||||
},
|
||||
add () {
|
||||
let len = this.list.length
|
||||
this.list.push({id: len + 1, title: 'title_' + len})
|
||||
}
|
||||
}
|
||||
|
||||
onLoad () {
|
||||
}
|
||||
}
|
||||
</script>
|
21
src/mixins/test.js
Normal file
21
src/mixins/test.js
Normal file
@ -0,0 +1,21 @@
|
||||
import wepy from 'wepy'
|
||||
|
||||
export default class testMixin extends wepy.mixin {
|
||||
data = {
|
||||
mixin: 'This is mixin data.'
|
||||
}
|
||||
methods = {
|
||||
tap () {
|
||||
this.mixin = 'mixin data was changed'
|
||||
console.log('mixin method tap')
|
||||
}
|
||||
}
|
||||
|
||||
onShow() {
|
||||
console.log('mixin onShow')
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
console.log('mixin onLoad')
|
||||
}
|
||||
}
|
239
src/pages/index.wpy
Normal file
239
src/pages/index.wpy
Normal file
@ -0,0 +1,239 @@
|
||||
<style lang="less">
|
||||
.userinfo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.userinfo-avatar {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.userinfo-nickname {
|
||||
color: #aaa;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="userinfo" @tap="handleViewTap">
|
||||
<image class="userinfo-avatar" src="{{ userInfo.avatarUrl }}" background-size="cover"/>
|
||||
<view class="userinfo-nickname">{{ userInfo.nickName }}</view>
|
||||
</view>
|
||||
|
||||
<panel>
|
||||
<view class="title" slot="title">测试数据绑定</view>
|
||||
|
||||
<text class="info">{{normalTitle}}</text>
|
||||
<text class="info">{{setTimeoutTitle}}</text>
|
||||
<text class="info">{{mixin}}</text>
|
||||
<text class="info">{{mynum}}</text>
|
||||
<text class="info">{{now}}</text>
|
||||
<button @tap="plus('a')" size="mini"> + </button>
|
||||
</panel>
|
||||
|
||||
<panel>
|
||||
<view class="title" slot="title">其它测试</view>
|
||||
<button @tap="toast" size="mini">第三方组件</button>
|
||||
<button @tap="communicate" size="mini">组件通信</button>
|
||||
<button @tap="tap" size="mini">混合TAP事件</button>
|
||||
</panel>
|
||||
|
||||
<panel>
|
||||
<view class="title" slot="title">测试并发网络请求</view>
|
||||
<view>返回结果: <text>{{netrst}}</text></view>
|
||||
<button @tap="request" size="mini"> 点我发起10个请求 </button>
|
||||
</panel>
|
||||
|
||||
<panel>
|
||||
<view class="title" slot="title">测试组件</view>
|
||||
|
||||
<text class="testcounter">计数组件1: </text>
|
||||
<view class="counterview">
|
||||
<counter1 @index-emit.user="counterEmit" />
|
||||
</view>
|
||||
|
||||
<text class="testcounter">计数组件2: </text>
|
||||
|
||||
<view class="counterview">
|
||||
<counter2 :num.sync="mynum"></counter2>
|
||||
</view>
|
||||
</panel>
|
||||
|
||||
<panel>
|
||||
<view class="title" slot="title">测试组件Repeat</view>
|
||||
<repeat for="" index="index" item="item" key="key">
|
||||
<group :grouplist="item" :indexa="index"></group>
|
||||
</repeat>
|
||||
</panel>
|
||||
|
||||
<panel>
|
||||
<view class="title" slot="title">测试列表</view>
|
||||
<list></list>
|
||||
</panel>
|
||||
|
||||
<toast />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import wepy from 'wepy'
|
||||
import Panel from '@/components/panel' // alias example
|
||||
import Counter from 'counter' // alias example
|
||||
import List from '../components/list' // aliasFields example
|
||||
import moduleA from 'module-a' // aliasFields ignore module example
|
||||
import Group from '../components/group'
|
||||
import Toast from 'wepy-com-toast'
|
||||
import testMixin from '../mixins/test'
|
||||
|
||||
console.log('moduleA ignored: ', moduleA) // => moduleA ignored: {}
|
||||
|
||||
|
||||
export default class Index extends wepy.page {
|
||||
config = {
|
||||
navigationBarTitleText: 'test'
|
||||
}
|
||||
components = {
|
||||
panel: Panel,
|
||||
counter1: Counter,
|
||||
counter2: Counter,
|
||||
list: List,
|
||||
group: Group,
|
||||
toast: Toast
|
||||
}
|
||||
|
||||
mixins = [testMixin]
|
||||
|
||||
data = {
|
||||
mynum: 20,
|
||||
userInfo: {
|
||||
nickName: '加载中...'
|
||||
},
|
||||
normalTitle: '原始标题',
|
||||
setTimeoutTitle: '标题三秒后会被修改',
|
||||
count: 0,
|
||||
netrst: '',
|
||||
groupList: [
|
||||
{
|
||||
id: 1,
|
||||
name: '点击改变',
|
||||
list: [
|
||||
{
|
||||
childid: '1.1',
|
||||
childname: '子项,点我改变'
|
||||
}, {
|
||||
childid: '1.2',
|
||||
childname: '子项,点我改变'
|
||||
}, {
|
||||
childid: '1.3',
|
||||
childname: '子项,点我改变'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '点击改变',
|
||||
list: [
|
||||
{
|
||||
childid: '2.1',
|
||||
childname: '子项,点我改变'
|
||||
}, {
|
||||
childid: '2.2',
|
||||
childname: '子项,点我改变'
|
||||
}, {
|
||||
childid: '2.3',
|
||||
childname: '子项,点我改变'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '点击改变',
|
||||
list: [
|
||||
{
|
||||
childid: '3.1',
|
||||
childname: '子项,点我改变'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
computed = {
|
||||
now () {
|
||||
return +new Date()
|
||||
}
|
||||
}
|
||||
|
||||
methods = {
|
||||
plus () {
|
||||
this.mynum++
|
||||
},
|
||||
toast () {
|
||||
let promise = this.$invoke('toast', 'show', {
|
||||
title: '自定义标题',
|
||||
img: 'https://raw.githubusercontent.com/kiinlam/wetoast/master/images/star.png'
|
||||
})
|
||||
|
||||
promise.then((d) => {
|
||||
console.log('toast done')
|
||||
})
|
||||
},
|
||||
tap () {
|
||||
console.log('do noting from ' + this.$name)
|
||||
},
|
||||
communicate () {
|
||||
console.log(this.$name + ' tap')
|
||||
|
||||
this.$invoke('counter2', 'minus', 45, 6)
|
||||
this.$invoke('counter1', 'plus', 45, 6)
|
||||
|
||||
this.$broadcast('index-broadcast', 1, 3, 4)
|
||||
},
|
||||
request () {
|
||||
let self = this
|
||||
let i = 10
|
||||
let map = ['MA==', 'MQo=', 'Mg==', 'Mw==', 'NA==', 'NQ==', 'Ng==', 'Nw==', 'OA==', 'OQ==']
|
||||
while (i--) {
|
||||
wepy.request({
|
||||
url: 'https://www.madcoder.cn/tests/sleep.php?time=1&t=css&c=' + map[i] + '&i=' + i,
|
||||
success: function (d) {
|
||||
self.netrst += d.data + '.'
|
||||
self.$apply()
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
counterEmit (...args) {
|
||||
let $event = args[args.length - 1]
|
||||
console.log(`${this.$name} receive ${$event.name} from ${$event.source.$name}`)
|
||||
}
|
||||
}
|
||||
|
||||
events = {
|
||||
'index-emit': (...args) => {
|
||||
let $event = args[args.length - 1]
|
||||
console.log(`${this.$name} receive ${$event.name} from ${$event.source.$name}`)
|
||||
}
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
let self = this
|
||||
this.$parent.getUserInfo(function (userInfo) {
|
||||
if (userInfo) {
|
||||
self.userInfo = userInfo
|
||||
}
|
||||
self.normalTitle = '标题已被修改'
|
||||
|
||||
self.setTimeoutTitle = '标题三秒后会被修改'
|
||||
setTimeout(() => {
|
||||
self.setTimeoutTitle = '到三秒了'
|
||||
self.$apply()
|
||||
}, 3000)
|
||||
|
||||
self.$apply()
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
69
wepy.config.js
Normal file
69
wepy.config.js
Normal file
@ -0,0 +1,69 @@
|
||||
const path = require('path');
|
||||
var prod = process.env.NODE_ENV === 'production';
|
||||
|
||||
module.exports = {
|
||||
wpyExt: '.wpy',
|
||||
eslint: false,
|
||||
cliLogs: !prod,
|
||||
build: {
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
counter: path.join(__dirname, 'src/components/counter'),
|
||||
'@': path.join(__dirname, 'src')
|
||||
},
|
||||
aliasFields: ['wepy', 'weapp'],
|
||||
modules: ['node_modules']
|
||||
},
|
||||
compilers: {
|
||||
less: {
|
||||
compress: prod
|
||||
},
|
||||
/*sass: {
|
||||
outputStyle: 'compressed'
|
||||
},*/
|
||||
babel: {
|
||||
sourceMap: true,
|
||||
presets: [
|
||||
'env'
|
||||
],
|
||||
plugins: [
|
||||
'transform-class-properties',
|
||||
'transform-decorators-legacy',
|
||||
'transform-object-rest-spread',
|
||||
'transform-export-extensions',
|
||||
]
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
},
|
||||
appConfig: {
|
||||
noPromiseAPI: ['createSelectorQuery']
|
||||
}
|
||||
}
|
||||
|
||||
if (prod) {
|
||||
|
||||
// 压缩sass
|
||||
// module.exports.compilers['sass'] = {outputStyle: 'compressed'}
|
||||
|
||||
// 压缩js
|
||||
module.exports.plugins = {
|
||||
uglifyjs: {
|
||||
filter: /\.js$/,
|
||||
config: {
|
||||
}
|
||||
},
|
||||
imagemin: {
|
||||
filter: /\.(jpg|png|jpeg)$/,
|
||||
config: {
|
||||
jpg: {
|
||||
quality: 80
|
||||
},
|
||||
png: {
|
||||
quality: 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user