step 18 sass(scss) 추가
@73e2fedf75af167e4a70d73d89a2c7db7043d245
--- README.md
+++ README.md
... | ... | @@ -79,7 +79,8 @@ |
| 79 | 79 |
- [Step 14. Browserify 로 React 번들링하기](./step14_react) |
| 80 | 80 |
- [Step 15. 다중 엔트리 React + Browserify + Watchify + Babel 빌드하기](./step15_watchify) |
| 81 | 81 |
- [Step 16. 수행할 작업을 메뉴에서 선택해서 실행하기](./step16_select_task) |
| 82 |
-- [Step 17. Webpack 으로 React 번들링하기 ](./step17_webpack) |
|
| 82 |
+- [Step 17. Webpack 으로 React 번들링하기](./step17_webpack) |
|
| 83 |
+- [Step 18. SASS(SCSS) 컴파일하고 자동으로 프리픽스 추가하기](./step18_sass) |
|
| 83 | 84 |
|
| 84 | 85 |
#### Gulp 를 활용하는데 도움이 되는 링크들 |
| 85 | 86 |
- [Gulp Recipes](https://github.com/gulpjs/gulp/tree/master/docs/recipes) |
+++ step18_sass/gulpfile.js
... | ... | @@ -0,0 +1,70 @@ |
| 1 | +var gulp = require('gulp');
| |
| 2 | +var uglify = require('gulp-uglify');
| |
| 3 | +var concat = require('gulp-concat');
| |
| 4 | +var sass = require('gulp-sass');
| |
| 5 | +var autoprefixer = require('gulp-autoprefixer');
| |
| 6 | +var minifycss = require('gulp-minify-css');
| |
| 7 | +var minifyhtml = require('gulp-minify-html');
| |
| 8 | +var plumber = require('gulp-plumber');
| |
| 9 | +var runSequence = require('run-sequence');
| |
| 10 | +var inquirer = require('inquirer');
| |
| 11 | + | |
| 12 | +var errorHandler = function (error) {
| |
| 13 | + console.error(error.message); | |
| 14 | + this.emit('end');
| |
| 15 | +}; | |
| 16 | +var plumberOption = {
| |
| 17 | + errorHandler: errorHandler | |
| 18 | +} | |
| 19 | + | |
| 20 | +gulp.task('minifyhtml', function () {
| |
| 21 | + return gulp.src('src/**/*.html')
| |
| 22 | + .pipe(plumber(plumberOption)) | |
| 23 | + .pipe(minifyhtml()) | |
| 24 | + .pipe(gulp.dest('dist'));
| |
| 25 | +}); | |
| 26 | + | |
| 27 | +gulp.task('uglify', function () {
| |
| 28 | + return gulp.src('src/**.*.js')
| |
| 29 | + .pipe(plumber(plumberOption)) | |
| 30 | + .pipe(uglify()) | |
| 31 | + .pipe(concat('main.js'))
| |
| 32 | + .pipe(gulp.dest('dist/js'));
| |
| 33 | +}); | |
| 34 | + | |
| 35 | +gulp.task('minifycss', function () {
| |
| 36 | + return gulp.src('src/**/*.scss')
| |
| 37 | + .pipe(plumber(plumberOption)) | |
| 38 | + .pipe(sass()) | |
| 39 | + .pipe(autoprefixer()) | |
| 40 | + .pipe(minifycss()) | |
| 41 | + .pipe(concat('main.css'))
| |
| 42 | + .pipe(gulp.dest('dist/css'));
| |
| 43 | +}); | |
| 44 | + | |
| 45 | +gulp.task('watch', function () {
| |
| 46 | + gulp.watch('src/**/*.js', ['uglify']);
| |
| 47 | + gulp.watch('src/**/*.css', ['minifycss']);
| |
| 48 | + gulp.watch('src/**/*.html', ['minifyhtml']);
| |
| 49 | +}); | |
| 50 | + | |
| 51 | +gulp.task('build', ['uglify', 'minifycss', 'minifyhtml']);
| |
| 52 | + | |
| 53 | +gulp.task('default', function (done) {
| |
| 54 | + inquirer.prompt([ | |
| 55 | + {
| |
| 56 | + type: 'list', | |
| 57 | + name: 'task', | |
| 58 | + message: '어떤 작업을 수행하시겠습니까?', | |
| 59 | + choices: [ | |
| 60 | + { name: 'JavaScript 빌드', value: 'uglify' },
| |
| 61 | + { name: 'CSS 빌드', value: 'minifycss' },
| |
| 62 | + { name: 'HTML 빌드', value: 'minifyhtml' },
| |
| 63 | + new inquirer.Separator(), | |
| 64 | + { name: '전체 빌드', value: 'build' }
| |
| 65 | + ] | |
| 66 | + } | |
| 67 | + ]).then(function (answers) {
| |
| 68 | + runSequence(answers.task, done); | |
| 69 | + }); | |
| 70 | +}); |
+++ step18_sass/package.json
... | ... | @@ -0,0 +1,29 @@ |
| 1 | +{ | |
| 2 | + "name": "gulp-step-by-step", | |
| 3 | + "version": "1.0.0", | |
| 4 | + "description": "gulp.js 를 시작하기 위한 간단한 예제들과 설명", | |
| 5 | + "main": "index.js", | |
| 6 | + "scripts": { | |
| 7 | + "test": "echo \"Error: no test specified\" && exit 1" | |
| 8 | + }, | |
| 9 | + "repository": { | |
| 10 | + "type": "git", | |
| 11 | + "url": "git+https://github.com/eu81273/gulp-step-by-step.git" | |
| 12 | + }, | |
| 13 | + "author": "AHN JAE-HA", | |
| 14 | + "license": "MIT", | |
| 15 | + "bugs": { | |
| 16 | + "url": "https://github.com/eu81273/gulp-step-by-step/issues" | |
| 17 | + }, | |
| 18 | + "devDependencies": { | |
| 19 | + "gulp": "^3.9.0", | |
| 20 | + "gulp-autoprefixer": "^3.1.1", | |
| 21 | + "gulp-concat": "^2.6.0", | |
| 22 | + "gulp-minify-css": "^1.2.1", | |
| 23 | + "gulp-minify-html": "^1.0.4", | |
| 24 | + "gulp-plumber": "^1.0.1", | |
| 25 | + "gulp-uglify": "^1.4.0", | |
| 26 | + "inquirer": "^1.1.0", | |
| 27 | + "run-sequence": "^1.1.5" | |
| 28 | + } | |
| 29 | +} |
+++ step18_sass/src/dummy.html
... | ... | @@ -0,0 +1,1 @@ |
| 1 | +<!-- 내용없음! --> |
+++ step18_sass/src/index.html
... | ... | @@ -0,0 +1,13 @@ |
| 1 | +<!DOCTYPE html> | |
| 2 | +<html lang="ko"> | |
| 3 | +<head> | |
| 4 | + <meta charset="UTF-8"> | |
| 5 | + <title>gulp example</title> | |
| 6 | + <link rel="stylesheet" type="text/css" href="css/main.css"> | |
| 7 | +</head> | |
| 8 | +<body> | |
| 9 | + <h2 id="title"></h2> | |
| 10 | + | |
| 11 | + <script src="js/main.js"></script> | |
| 12 | +</body> | |
| 13 | +</html> |
+++ step18_sass/src/js/main.js
... | ... | @@ -0,0 +1,3 @@ |
| 1 | +(function () { | |
| 2 | + document.getElementById('title').text = "Hello World!" | |
| 3 | +})(); |
+++ step18_sass/src/scss/dummy.scss
... | ... | @@ -0,0 +1,25 @@ |
| 1 | +//기본 색상 | |
| 2 | +$base-color: #777; | |
| 3 | +$point-color: #369; | |
| 4 | + | |
| 5 | +h2 {
| |
| 6 | + color: $base-color; | |
| 7 | + small {
| |
| 8 | + color: lighten($base-color, 10%); | |
| 9 | + } | |
| 10 | +} | |
| 11 | + | |
| 12 | +h3 {
| |
| 13 | + color: darken($base-color, 10%); | |
| 14 | +} | |
| 15 | + | |
| 16 | +.button {
| |
| 17 | + border: 1px solid black; | |
| 18 | + &:hover {
| |
| 19 | + background-color: $point-color; | |
| 20 | + } | |
| 21 | +} | |
| 22 | + | |
| 23 | +a {
| |
| 24 | + display: flex; | |
| 25 | +} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?