Skip to content

Commit 8c16a6f

Browse files
authored
feat:完善构建过程 (#694)
* feat(button):新增l-label-class外部样式类 * feat(example):清除示例代码wx:for的warning * feat(package.json):更改homepage地址 * feat(build):更改husky信息 * feat(package.json): 增加husky校验commit
1 parent e501bc6 commit 8c16a6f

File tree

202 files changed

+490
-7755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+490
-7755
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/*.js
2+
config/*.js
3+
example/*.js
4+
dist

build/build.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

build/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
const {
22
buildWxss,
3+
buildWxml,
4+
buildImage,
5+
buildJson,
6+
buildJs,
37
copyStatic,
48
clean,
59
copy
6-
} = require('./build');
10+
} = require('./task');
711
const {
812
series,
913
parallel,
@@ -30,6 +34,23 @@ module.exports = {
3034
`!${srcProPath}/_*.less`,
3135
distPath
3236
),
37+
buildWxml(
38+
`${srcProPath}/*.wxml`,
39+
`!${srcProPath}/_*.wxml`,
40+
distPath
41+
),
42+
buildImage(
43+
`${srcProPath}/*.png`,
44+
distPath
45+
),
46+
buildJson(
47+
`${srcProPath}/*.json`,
48+
distPath
49+
),
50+
buildJs(
51+
`${srcProPath}/*.js`,
52+
distPath
53+
),
3354
copyStatic(
3455
srcProPath,
3556
distPath
@@ -46,7 +67,8 @@ module.exports = {
4667
),
4768
copyStatic(
4869
srcDevPath,
49-
examplePath
70+
examplePath,
71+
'dev'
5072
)
5173
)
5274
),

build/task.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
const {
2+
src,
3+
dest,
4+
parallel
5+
} = require('gulp');
6+
const less = require('gulp-less');
7+
const imagemin = require('gulp-imagemin');
8+
const cssmin = require('gulp-clean-css');
9+
const jsonmin = require('gulp-jsonminify');
10+
const jsmin = require('gulp-uglify-es').default;
11+
const wxmlmin = require('gulp-htmlmin');
12+
const rename = require('gulp-rename');
13+
const del = require('del');
14+
15+
const buildWxss = (srcPath, remainPath, distPath) => () =>
16+
src([srcPath, remainPath])
17+
.pipe(less())
18+
.pipe(cssmin())
19+
.pipe(rename(srcPath => {
20+
srcPath.extname = '.wxss';
21+
}))
22+
.pipe(dest(distPath));
23+
24+
const copy = (srcPath, distPath, ext) => () =>
25+
src(`${srcPath}/*.${ext}`)
26+
.pipe(dest(distPath));
27+
28+
const buildWxml = (srcPath, remainPath, distPath) => () =>
29+
src([srcPath, remainPath])
30+
.pipe(wxmlmin({
31+
removeComments: true,
32+
// collapseWhitespace: true,
33+
keepClosingSlash: true,
34+
caseSensitive: true
35+
}))
36+
.pipe(dest(distPath));
37+
38+
const buildJson = (srcPath, distPath) => () =>
39+
src(srcPath)
40+
.pipe(jsonmin())
41+
.pipe(dest(distPath));
42+
43+
const buildJs = (srcPath, distPath) => () =>
44+
src(srcPath)
45+
.pipe(jsmin())
46+
.pipe(dest(distPath));
47+
48+
const buildImage = (srcPath, distPath) => () =>
49+
src(srcPath)
50+
.pipe(imagemin())
51+
.pipe(dest(distPath));
52+
53+
const copyStatic = (srcPath, distPath, env = 'build') => {
54+
if (env === 'build') {
55+
return parallel(
56+
copy(srcPath, distPath, 'wxs')
57+
);
58+
} else {
59+
return parallel(
60+
copy(srcPath, distPath, 'wxml'),
61+
copy(srcPath, distPath, 'wxs'),
62+
copy(srcPath, distPath, 'json'),
63+
copy(srcPath, distPath, 'js'),
64+
copy(srcPath, distPath, 'png')
65+
);
66+
}
67+
}
68+
69+
const clean = (cleanPath) => () =>
70+
del([cleanPath], {
71+
force: true
72+
});
73+
74+
module.exports = {
75+
buildWxss,
76+
buildWxml,
77+
buildImage,
78+
buildJson,
79+
buildJs,
80+
copyStatic,
81+
clean,
82+
copy
83+
};

dist/action-sheet/index.js

Lines changed: 1 addition & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/action-sheet/index.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
{
2-
"component": true,
3-
"usingComponents": {
4-
"l-icon":"../icon/index",
5-
"l-popup":"../popup/index",
6-
"l-button":"../button/index"
7-
}
8-
}
1+
{"component":true,"usingComponents":{"l-icon":"../icon/index","l-popup":"../popup/index","l-button":"../button/index"} }

dist/action-sheet/index.wxml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<l-popup show="{{show}}" showMask="{{true}}" contentAlign="bottom" locked="{{locked}}" bind:lintap="handleClickPopUp" z-index="{{zIndex}}">
2-
<view class='l-action-sheet'>
3-
<view class="l-item-button l-class-title l-title-class" wx:if="{{title}}">
2+
<view class="l-action-sheet">
3+
<view class="l-item-button l-class-title l-title-class" wx:if="{{title}}">
44
{{ title }}
55
</view>
66
<view wx:for="{{ itemList }}" wx:key="name" hover-class="{{isHover?'list-hover':''}}">
77
<l-button bind:lintap="handleClickItem" data-index="{{ index }}" data-item="{{ item }}" open-type="{{ item.openType }}" icon="{{ item.icon }}" type="ghost" size="large" special="{{true}}" long>
88
<view style="{{ item.color ? 'color: ' + item.color : '' }}" class="l-item-button l-class-item l-item-class {{item.image || item.icon ? 'l-image-button':''}}">
99
<image wx:if="{{item.image}}" class="l-button-image" src="{{item.image}}" style="{{item.imageStyle}}"/>
10-
<l-icon
11-
wx:elif="{{ item.icon }}"
12-
name="{{ item.icon }}"
13-
l-class="l-item-button"
14-
size="{{ item.iconSize }}"
15-
color="{{item.iconColor?item.iconColor:item.color}}"></l-icon>
10+
<l-icon wx:elif="{{ item.icon }}" name="{{ item.icon }}" l-class="l-item-button" size="{{ item.iconSize }}" color="{{item.iconColor?item.iconColor:item.color}}"></l-icon>
1611
<text class="l-button-text">{{ item.name }}</text>
1712
</view>
1813
</l-button>

0 commit comments

Comments
 (0)