Skip to content

Commit 1523ce4

Browse files
committed
Initial commit
0 parents  commit 1523ce4

File tree

7 files changed

+335
-0
lines changed

7 files changed

+335
-0
lines changed

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Generic
3+
#
4+
5+
# OS
6+
.DS_Store
7+
.DS_Store?
8+
*[Tt]humbs.db
9+
.Spotlight-V100
10+
.Trashes
11+
.Trash-1000/
12+
*.Trashes
13+
14+
._*
15+
*.log
16+
.idea/
17+
.tmp/
18+
19+
bower_components/
20+
node_modules/
21+
22+
#
23+
# Conventional
24+
#
25+
26+
local/
27+
public/
28+
29+
#
30+
# PhoneGap / Cordova
31+
#
32+
33+
#platforms
34+
#plugins
35+
#.bithoundrc

.jshintrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"node": true,
3+
"browser": true,
4+
"esnext": true,
5+
"bitwise": true,
6+
"camelcase": false,
7+
"curly": true,
8+
"freeze": true,
9+
"immed": true,
10+
"indent": 2,
11+
"latedef": true,
12+
"newcap": true,
13+
"noarg": true,
14+
"quotmark": "single",
15+
"regexp": true,
16+
"notypeof": true,
17+
"undef": true,
18+
"unused": true,
19+
"strict": true,
20+
"trailing": true,
21+
"smarttabs": true,
22+
"proto": true,
23+
"laxbreak": true,
24+
"predef": [
25+
26+
]
27+
}

.npmignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generic
2+
3+
*.log
4+
._*
5+
gulpfile.js
6+
gulpfile.babel.js
7+
.jshintrc
8+
.eslintrc
9+
.babelrc
10+
.gitignore
11+
test/
12+
#src/
13+
bower_components/
14+
node_modules/
15+
local/
16+
public/
17+
doc/
18+
docs/
19+
examples/
20+
tasks/
21+
.Trashes
22+
.Trash-1000/
23+
.Spotlight-V100
24+
.DS_Store
25+
.DS_Store?
26+
Thumbs.db
27+
.tmp/
28+
.idea/

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
gulp-flow-css - https://github.com/gulp-flow/gulp-flow-css
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2016 Nicolas Tallefourtane <dev@nicolab.net>
6+
7+
Permission is hereby granted, free of charge, to any person obtaining
8+
a copy of this software and associated documentation files (the
9+
"Software"), to deal in the Software without restriction, including
10+
without limitation the rights to use, copy, modify, merge, publish,
11+
distribute, sublicense, and/or sell copies of the Software, and to
12+
permit persons to whom the Software is furnished to do so, subject to
13+
the following conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# gulp-flow-css
2+
3+
CSS, SASS, LESS bundle for [gulp-flow](https://github.com/gulp-flow/gulp-flow).
4+
5+
6+
## Requirements
7+
8+
* [gulp-flow](https://github.com/gulp-flow/gulp-flow) must be installed.
9+
10+
11+
## Install
12+
13+
```sh
14+
npm install --save-dev gulp-flow-css
15+
```
16+
17+
or
18+
19+
```sh
20+
yarn add --dev gulp-flow-css
21+
```
22+
23+
24+
## Usage
25+
26+
By default this bundle is preconfigured in `cfg.css`.
27+
28+
This module adds some `gp` (Gulp plugins):
29+
30+
* gp.postcss
31+
* gp.cssnano
32+
* gp.less
33+
* gp.sass
34+
35+
And `pipes`:
36+
37+
* pipes.devSassBundle (NODE_ENV=development)
38+
* pipes.prodSassBundle (NODE_ENV=production)
39+
* pipes.devLessBundle (NODE_ENV=development)
40+
* pipes.prodLessBundle (NODE_ENV=production)
41+
* pipes.devCssBundle (NODE_ENV=development)
42+
* pipes.prodCssBundle (NODE_ENV=production)
43+
44+
And push ignored files in `cfg.files`.
45+
46+
See the source code for more details.
47+
48+
### Task
49+
50+
A common use case:
51+
52+
```js
53+
'use strict';
54+
55+
require('gulp-flow-css');
56+
57+
// build: CSS
58+
gulp.task('build.css', function() {
59+
return gulp.src(cfg.css.src)
60+
.pipe(gp.newer(cfg.publicCssDir))
61+
// .pipe(gp.using())
62+
.pipe(gp.ifElse(
63+
envList.NODE_ENV === 'production',
64+
pipes.prodCssBundle,
65+
pipes.devCssBundle
66+
))
67+
.pipe(gulp.dest(cfg.publicCssDir))
68+
;
69+
});
70+
```
71+
72+
And run your tasks: `APP_ENV=dev gulp`
73+
74+
75+
## LICENSE
76+
77+
[MIT](https://github.com/gulp-flow/gulp-flow-css/blob/master/LICENSE) (c) 2016, Nicolas Tallefourtane.
78+
79+
80+
## Author
81+
82+
| [![Nicolas Tallefourtane - Nicolab.net](https://www.gravatar.com/avatar/d7dd0f4769f3aa48a3ecb308f0b457fc?s=64)](https://nicolab.net) |
83+
|---|
84+
| [Nicolas Talle](https://nicolab.net) |
85+
| [![Make a donation via Paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PGRH4ZXP36GUC) |

package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "gulp-flow-css",
3+
"version": "2.0.0",
4+
"description": "CSS, LESS bundle for gulp-flow.",
5+
"main": "./src/index.js",
6+
"keywords": [
7+
"gulp",
8+
"gulpfriendly",
9+
"gulp-flow-bundle",
10+
"workflow",
11+
"task",
12+
"plugin",
13+
"bundle",
14+
"assets",
15+
"css",
16+
"less"
17+
],
18+
"homepage": "https://github.com/gulp-flow/gulp-flow-css",
19+
"author": {
20+
"name": "Nicolas Tallefourtane",
21+
"url": "https://nicolab.net"
22+
},
23+
"license": "MIT",
24+
"repository": {
25+
"type": "git",
26+
"url": "git@github.com:gulp-flow/gulp-flow-css.git"
27+
},
28+
"bugs": "https://github.com/gulp-flow/gulp-flow-css/issues",
29+
"dependencies": {
30+
"autoprefixer": "^9.5.1",
31+
"gulp-cssnano": "^2.1.3",
32+
"gulp-less": "^4.0.1",
33+
"gulp-postcss": "^8.0.0",
34+
"gulp-sass": "^4.0.2"
35+
},
36+
"peerDependencies": {
37+
"gulp-flow": ">=2 <3"
38+
},
39+
"engines": {
40+
"node": ">= 10"
41+
}
42+
}

src/index.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* This file is part of gulp-flow-css.
3+
*
4+
* (c) Nicolas Tallefourtane <dev@nicolab.net>
5+
*
6+
* For the full copyright and license information, please view the LICENSE file
7+
* distributed with this source code.
8+
*/
9+
10+
'use strict';
11+
12+
let autoprefixer = require('autoprefixer');
13+
let flow = require('gulp-flow');
14+
let {cfg, gp, pipes, utils} = flow;
15+
let {lazypipe} = utils;
16+
let {srcDir, notSrcDir, nodeModulesPath} = cfg;
17+
18+
19+
/*----------------------------------------------------------------------------*\
20+
Gulp plugins
21+
\*----------------------------------------------------------------------------*/
22+
23+
gp.postcss = require('gulp-postcss');
24+
gp.cssnano = require('gulp-cssnano');
25+
gp.less = require('gulp-less');
26+
gp.sass = require('gulp-sass');
27+
28+
29+
/*----------------------------------------------------------------------------*\
30+
Config
31+
\*----------------------------------------------------------------------------*/
32+
33+
cfg.css = {
34+
src: [
35+
srcDir + '/assets/css/**/*.{css,scss,less}'
36+
].concat(cfg.patterns.ignore),
37+
38+
srcWatch: [
39+
srcDir + '/assets/css/**/*.{css,scss,less}'
40+
],
41+
sass: {
42+
includePaths: [nodeModulesPath]
43+
},
44+
less: {
45+
paths: [nodeModulesPath]
46+
},
47+
autoprefixer: {browsers: ['last 3 versions', 'safari >= 8']}
48+
};
49+
50+
// ignore CSS in files tasks
51+
cfg.files.src.push(
52+
notSrcDir + '/assets/css/**/*.{css,scss,less}'
53+
);
54+
55+
cfg.files.srcWatch.push(
56+
notSrcDir + '/assets/css/**/*.{css,scss,less}'
57+
);
58+
59+
60+
/*----------------------------------------------------------------------------*\
61+
Pipes
62+
\*----------------------------------------------------------------------------*/
63+
64+
// NODE_ENV: development
65+
pipes.devSassBundle = lazypipe()
66+
.pipe(gp.sass, cfg.css.sass)
67+
// .pipe(
68+
// function (opt, cb) {
69+
// return gp.sass(opt).on('error', cb);
70+
// },
71+
// cfg.css.sass,
72+
// gp.sass.logError
73+
// )
74+
;
75+
76+
pipes.devLessBundle = lazypipe()
77+
.pipe(gp.less, cfg.css.less)
78+
;
79+
80+
pipes.devCssBundle = lazypipe()
81+
.pipe(function() {
82+
// .less by devLessBundle, other files (.css, .scss, .sass) by devSassBundle
83+
return gp.if('*.less', pipes.devLessBundle(), pipes.devSassBundle());
84+
})
85+
.pipe(gp.concat, 'app.css')
86+
;
87+
88+
// NODE_ENV: production
89+
pipes.prodCssBundle = pipes.devCssBundle
90+
.pipe(gp.postcss, [autoprefixer(cfg.css.autoprefixer)])
91+
.pipe(gp.cssnano)
92+
.pipe(gp.header, cfg.banner)
93+
;
94+

0 commit comments

Comments
 (0)