Skip to content

Commit

Permalink
build: reorganization order and add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfBramble committed Sep 3, 2020
1 parent 9a97115 commit acc682b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 26 deletions.
18 changes: 18 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**/*.svg
package.json
/dist
.dockerignore
.DS_Store
.eslintignore
*.png
*.toml
docker
.editorconfig
Dockerfile*
.gitignore
.prettierignore
LICENSE
.eslintcache
*.lock
yarn-error.log
.history
15 changes: 15 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
module.exports = {
singleQuote: true,
trailingComma: 'all',
printWidth: 100,
proseWrap: 'never',
overrides: [
{
files: '.prettierrc',
options: {
parser: 'json',
},
},
],
};
50 changes: 26 additions & 24 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
const { src, dest,parallel } = require('gulp');
const { src, dest, parallel } = require('gulp');
const through = require('through2');
const sass=require('gulp-sass');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
function outputStyleTask () {
function outputStyleTask() {
return src(['src/components/**/*.scss'])
.pipe(through.obj(function (file, _, callback) {
const pathName=file.relative.split('/')[0]
this.push(pathName)
callback()
}))
.on('data', (data) => {
convertStyles(data)
})
.pipe(
through.obj(function(file, _, callback) {
const pathName = file.relative.split('/')[0];
this.push(pathName);
callback();
}),
)
.on('data', data => {
convertStyles(data);
});
}
function convertStyles(data){
return src(['src/components/'+String(data)+'/*.scss'])
.pipe(dest('lib/'+String(data)+'/style/'))
.pipe(sass())
.pipe(dest('lib/'+String(data)+'/style/'))
function convertStyles(data) {
return src(['src/components/' + String(data) + '/*.scss'])
.pipe(dest('lib/' + String(data) + '/style/'))
.pipe(sass())
.pipe(dest('lib/' + String(data) + '/style/'));
}

//管道输出后会引用新位置,因此css和scss单独两个task
function globalSass(){
function globalSass() {
return src('src/components/**/*.scss') //建议单独建个文件夹摆放,考虑到其他项目应用时也需相应更改,所以暂时先放打包文件根目录
.pipe(concat('index.scss'))
.pipe(dest('lib'))
.pipe(concat('index.scss'))
.pipe(dest('lib'));
}

function globalCss(){
function globalCss() {
return src('src/components/**/*.scss')
.pipe(concat('index.css'))
.pipe(sass())
.pipe(dest('lib'))
.pipe(concat('index.css'))
.pipe(sass())
.pipe(dest('lib'));
}
exports.default = parallel(outputStyleTask,globalCss,globalSass)
exports.default = parallel(outputStyleTask, globalCss, globalSass);
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"module": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"gulp": "gulp",
"build-css": "gulp",
"increase-memory-limit": "cross-env LIMIT=8096 increase-memory-limit",
"storybook": "start-storybook -p 9001 -c .storybook",
"build-storybook": "export NODE_ENV='production' && build-storybook -c .storybook -o dist",
"build": "npm run build-ts && npm run gulp",
"compile": "rm -rf lib && npm run build-ts && npm run build-css",
"build-ts": "tsc -p tsconfig.build.json",
"release": "./scripts/release.sh",
Expand Down

0 comments on commit acc682b

Please sign in to comment.