Skip to content

Commit

Permalink
feat: add css build and remove sass-node to build global style
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfBramble committed Sep 3, 2020
1 parent 0636f6a commit 9a97115
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
20 changes: 17 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {src, dest,series} = require('gulp');
const { src, dest,parallel } = require('gulp');
const through = require('through2');
const sass=require('gulp-sass');
const concat = require('gulp-concat');
function outputStyleTask () {
return src(['src/components/**/*.scss'])
.pipe(through.obj(function (file, _, callback) {
Expand All @@ -13,10 +14,23 @@ function outputStyleTask () {
})
}
function convertStyles(data){
console.log('src/components/'+String(data)+'/*.scss')
return src(['src/components/'+String(data)+'/*.scss'])
.pipe(dest('lib/'+String(data)+'/style/'))
.pipe(sass())
.pipe(dest('lib/'+String(data)+'/style/'))
}
exports.default = outputStyleTask

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

function globalCss(){
return src('src/components/**/*.scss')
.pipe(concat('index.css'))
.pipe(sass())
.pipe(dest('lib'))
}
exports.default = parallel(outputStyleTask,globalCss,globalSass)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"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",
"build-css": "node-sass ./src/styles/index.scss ./lib/index.css",
"release": "./scripts/release.sh",
"deploy-storybook": "storybook-to-ghpages",
"deploy": "./scripts/deploy.sh",
Expand Down Expand Up @@ -113,6 +112,7 @@
"eslint-plugin-standard": "^4.0.0",
"file-loader": "^6.0.0",
"gulp": "^4.0.2",
"gulp-concat": "^2.6.1",
"gulp-eslint": "^6.0.0",
"gulp-sass": "^4.1.0",
"husky": "^1.2.0",
Expand Down
16 changes: 16 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6487,6 +6487,13 @@ concat-stream@^1.5.0, concat-stream@^1.6.0:
readable-stream "^2.2.2"
typedarray "^0.0.6"

concat-with-sourcemaps@^1.0.0:
version "1.1.0"
resolved "https://registry.npm.taobao.org/concat-with-sourcemaps/download/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e"
integrity sha1-1OqT8FriV5CVG5nns7CeOQikCC4=
dependencies:
source-map "^0.6.1"

console-browserify@^1.1.0:
version "1.2.0"
resolved "https://registry.npm.taobao.org/console-browserify/download/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336"
Expand Down Expand Up @@ -9149,6 +9156,15 @@ gulp-cli@^2.2.0:
v8flags "^3.2.0"
yargs "^7.1.0"

gulp-concat@^2.6.1:
version "2.6.1"
resolved "https://registry.npm.taobao.org/gulp-concat/download/gulp-concat-2.6.1.tgz#633d16c95d88504628ad02665663cee5a4793353"
integrity sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=
dependencies:
concat-with-sourcemaps "^1.0.0"
through2 "^2.0.0"
vinyl "^2.0.0"

gulp-eslint@^6.0.0:
version "6.0.0"
resolved "https://registry.npm.taobao.org/gulp-eslint/download/gulp-eslint-6.0.0.tgz#7d402bb45f8a67652b868277011812057370a832"
Expand Down

0 comments on commit 9a97115

Please sign in to comment.