Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies, fix css-sass.js #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
node_modules/
.DS_Store
.DS_Store
package-lock.json
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [enb](https://github.com/enb-make/enb)-sass [![npm version](https://img.shields.io/badge/npm-v1.0.1-blue.svg)](https://www.npmjs.com/package/enb-sass) [![node-sass supports version](https://img.shields.io/badge/node--sass-3.2.0-orange.svg)](https://github.com/sass/node-sass/tree/v2) [![Build Status](https://travis-ci.org/enb-make/enb-sass.svg?branch=master)](https://travis-ci.org/enb-make/enb-sass) [![Dependency Status](https://david-dm.org/enb-make/enb-sass.svg)](https://david-dm.org/enb-make/enb-sass)
# [enb](https://github.com/enb-make/enb)-sass [![npm version](https://img.shields.io/badge/npm-v1.0.1-blue.svg)](https://www.npmjs.com/package/enb-sass) [![node-sass supports version](https://img.shields.io/badge/sass-1.49.8-orange.svg)](https://github.com/sass/sass/) [![Build Status](https://travis-ci.org/enb-make/enb-sass.svg?branch=master)](https://travis-ci.org/enb-make/enb-sass) [![Dependency Status](https://david-dm.org/enb-make/enb-sass.svg)](https://david-dm.org/enb-make/enb-sass)

Provides the `node-sass` features for project-builder `enb` (https://github.com/enb-make/enb).

Expand All @@ -15,7 +15,7 @@ npm install enb-sass --save
* *String* **target** contains target file name. Default: `?.css`
* *String* **filesTarget** contains file masks, according to which a list of source files is created. Default: `?.files`.
* *Array* **sourceSuffixes** Files suffixes that will be used. Default: `css`
* *Object* **sass** `node-sass` options. Read more: https://github.com/sass/node-sass#options. Default: default `node-sass` options.
* *Object* **sass** `sass` options. Read more: [SharedOptions](https://sass-lang.com/documentation/js-api/interfaces/LegacySharedOptions), [FileOptions](https://sass-lang.com/documentation/js-api/interfaces/LegacyFileOptions), [StringOptions](https://sass-lang.com/documentation/js-api/interfaces/LegacyStringOptions). Default: default `sass` options.


## Usage
Expand All @@ -39,7 +39,7 @@ nodeConfig.addTech([
]);
```

#### Use `node-sass` [compression](https://github.com/sass/node-sass#outputstyle) and [debug mode](https://github.com/sass/node-sass#sourcecomments)
#### Use `sass` [compression](https://sass-lang.com/documentation/js-api/interfaces/LegacySharedOptions#outputStyle)

```javascript
nodeConfig.addTech([
Expand All @@ -48,14 +48,13 @@ nodeConfig.addTech([
target: '?.css',
sourceSuffixes: ['scss'],
sass: {
outputStyle: 'compressed',
sourceComments: true
outputStyle: 'compressed'
}
}
]);
```

#### Collecting ie and ie8 css/scss files with `node-sass` [compression](https://github.com/sass/node-sass#outputstyle) and [debug mode](https://github.com/sass/node-sass#sourcecomments)
#### Collecting ie and ie8 css/scss files with `sass` [compression](https://sass-lang.com/documentation/js-api/interfaces/LegacySharedOptions#outputStyle)

```javascript
nodeConfig.addTech([
Expand All @@ -64,8 +63,7 @@ nodeConfig.addTech([
target: '?.css',
sourceSuffixes: ['css', 'scss', 'ie.css', 'ie.scss', 'ie8.css', 'ie8.scss'],
sass: {
outputStyle: 'compressed',
sourceComments: true
outputStyle: 'compressed'
}
}
]);
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"github-username": "ixax"
}
],
"dependencies" : {
"enb": "0.15.0",
"node-sass": "3.3.3",
"vow": "0.4.9",
"inherit": "2.2.2"
"dependencies": {
"enb": "1.5.1",
"enb-css-preprocessor": "1.0.0",
"sass": "1.49.8",
"vow": "0.4.20"
},
"engines": {
"node": ">=0.10"
Expand Down
18 changes: 10 additions & 8 deletions techs/css-sass.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var sass = require('node-sass');
var sass = require('sass');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можешь, пожалуйста, заодно актуализировать комментарий на 14 строке?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tadatuta , готово

var Vow = require('vow');
var inherit = require('inherit');
var CssPreprocessor = require('enb/lib/preprocess/css-preprocessor');
var CssPreprocessor = require('enb-css-preprocessor');
var vowFs = require('enb/lib/fs/async-fs');
var path = require('path');
var util = require('util');
Expand All @@ -12,15 +11,19 @@ Logger = new Logger();
module.exports = require('enb/lib/build-flow').create()
.name('enb-sass')
.target('target', '?.css')
.defineOption('sass', {}) // https://github.com/sass/node-sass#options
// https://sass-lang.com/documentation/js-api/interfaces/LegacySharedOptions
// https://sass-lang.com/documentation/js-api/interfaces/LegacyFileOptions
// https://sass-lang.com/documentation/js-api/interfaces/LegacyStringOptions
.defineOption('sass', {})
.useFileList(['css', 'scss'])
.builder(function (sourceFiles) {
var _this = this;
var deferred = Vow.defer();
var sassSettings = inherit({
var sassSettings = {
includePaths: [],
data: ''
}, this._sass);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это изменение не понимаю, в таком случае ведь перестают прокидываться внешние опции?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tadatuta , в перый раз года дебажил sassSettings обёрнутый в inherit возвращал undefined, поэтому решил оставить просто объект.

поправил чтобы sass опции добавлялись в sassSettings через спред оператор

data: '',
..._this._options.sass
};
var errorLogging = {
enabled: true,
offsetLines: 5
Expand Down Expand Up @@ -66,7 +69,6 @@ module.exports = require('enb/lib/build-flow').create()
deferred.resolve(cssResult);
} catch (ex) {
ex = ex instanceof Error ? ex : JSON.parse(ex);

var lines = sassSettings.data.split('\n');
var errorCtx = lines.slice(ex.line - errorLogging.offsetLines, ex.line).concat(
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',
Expand Down