@es-pkg/compile 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/index.ts +20 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@es-pkg/compile",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "组件打包工具",
5
5
  "main": "src/index.ts",
6
6
  "keywords": [
@@ -24,6 +24,7 @@
24
24
  "gulp-autoprefixer": "^8.0.0",
25
25
  "gulp-babel": "^8.0.0",
26
26
  "gulp-sass": "^5.1.0",
27
+ "gulp-less": "^5.0.0",
27
28
  "gulp-typescript": "^6.0.0-alpha.1",
28
29
  "gulp-plumber": "latest",
29
30
  "gulp-rename": "latest",
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import ts from "gulp-typescript"
5
5
  import typescript from "typescript"
6
6
  import babel from "gulp-babel"
7
7
  import gulpSass from "gulp-sass";
8
+ import gulpLess from "gulp-less";
8
9
  import rename from "gulp-rename";
9
10
  import autoPreFixer from "gulp-autoprefixer"
10
11
  import Sass from "sass";
@@ -39,31 +40,34 @@ const clean = () => {
39
40
  }
40
41
 
41
42
 
42
- const dealScss = () => {
43
+ const cssPreprocess = () => {
43
44
  const copy = (dest: string) => {
44
45
  return () => gulp.src(
45
- getMatchFiles((path) => `${path}/**/*.scss`, false)
46
+ getMatchFiles((path) => [`${path}/**/*.scss`, `${path}/**/*.less`], false)
46
47
  ).pipe(logger({
47
- before: `copyScss...`,
48
- after: 'copyScss complete!',
49
- extname: '.scss',
48
+ before: `copyPreprocessCSS...`,
49
+ after: 'copyPreprocessCSS complete!',
50
50
  showChange: true
51
- }))
52
- .pipe(gulp.dest(dest))
51
+ })).pipe(gulp.dest(dest))
53
52
  }
54
- const compileScss = () => {
55
- return gulp.src(
56
- getMatchFiles((path) => `${path}/**/*.scss`, false)
53
+ const compilePreprocess = (extname: string, dest: string) => {
54
+ return () => gulp.src(
55
+ getMatchFiles((path) => `${path}/**/*.${extname}`, false)
57
56
  )
58
- .pipe(sass({outputStyle: 'compressed', outFile: 'xx'}).on('error', sass.logError))
57
+ .pipe(extname === 'less'
58
+ ? gulpLess()
59
+ : sass({outputStyle: 'compressed'}).on('error', sass.logError))
59
60
  .pipe(autoPreFixer())
60
61
  .pipe(rename((path) => {
61
62
  path.extname = ".min.css"
62
63
  }))
63
64
  .pipe(plumber())
64
- .pipe(gulp.dest(config.cjs));
65
+ .pipe(gulp.dest(dest));
66
+ }
67
+ const compile = (dest: string) => {
68
+ return parallel(compilePreprocess('scss', dest), compilePreprocess('less', dest))
65
69
  }
66
- return parallel(copy(config.es), copy(config.cjs), compileScss)
70
+ return parallel(copy(config.es), copy(config.cjs), compile(config.cjs), compile(config.es))
67
71
  }
68
72
 
69
73
 
@@ -130,9 +134,9 @@ const compileEs = () => {
130
134
  const tasks = include.map((item) => {
131
135
  const isDirectory = item.isDirectory;
132
136
  return () => compile(isDirectory ? [
133
- `${item.path}/**/*`,
137
+ `${item.path}/**/*.{ts,tsx}`,
134
138
  `!${item.path}/**/__test__/!**`,
135
- `${config.typings}/**/*`,
139
+ `${config.typings}/**/*.ts`,
136
140
  ] : [item.path],
137
141
  isDirectory && include.length > 1 ?
138
142
  path.join(config.es, relativeToApp(item.path))
@@ -183,4 +187,4 @@ const compileLib = () => {
183
187
 
184
188
  const compileEsAndLib = series(compileEs(), copyTds, compileLib)
185
189
 
186
- export default series(clean, parallel(dealScss(), copyScssToLib, compileEsAndLib))
190
+ export default series(clean, parallel(cssPreprocess(), copyScssToLib, compileEsAndLib))