Skip to content

Commit 2dbff6c

Browse files
authored
Merge pull request #84 from csgibson/refactor-sass
refactor(sass): allow sass to be used as a scss compiler
2 parents 651ec58 + 287586c commit 2dbff6c

File tree

12 files changed

+61
-6
lines changed

12 files changed

+61
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# opensphere-build-resolver
22

3-
Resolves sources and other input for the Google Closure Compiler, sass for node-sass, template views for angular, and other items through a project's dependency tree.
3+
Resolves sources and other input for the Google Closure Compiler, scss for sass/node-sass, template views for angular, and other items through a project's dependency tree.
44

55
## Problem
6-
You want to use npm to manage your project and its dependencies, but you need to resolve source, css, sass, templates, or other resources from those dependencies and pass them as arguments on the command line to tools like the google-closure-compiler, node-sass, and others.
6+
You want to use npm to manage your project and its dependencies, but you need to resolve source, css, scss, templates, or other resources from those dependencies and pass them as arguments on the command line to tools like the google-closure-compiler, sass/node-sass, and others.
77

88
## Solution
99
This.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "opensphere-build-resolver",
33
"version": "8.0.0",
4-
"description": "Resolves projects, their dependencies, plugins, and config to the correct arguments for compilation via the Google Closure Compiler, node-sass, and other tools.",
4+
"description": "Resolves projects, their dependencies, plugins, and config to the correct arguments for compilation via the Google Closure Compiler, sass/node-sass, and other tools.",
55
"bin": {
66
"os-resolve": "./resolve.js"
77
},

plugins/scss/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,16 @@ const addScssRequires = function(pack, dir) {
156156

157157
const writer = function(thisPackage, outputDir) {
158158
if (scssPaths.length || scssEntries.length) {
159-
var options = {
160-
'include-path': scssPaths
161-
};
159+
var options = {};
160+
if ((thisPackage.build && thisPackage.build.scssCompiler === 'sass') ||
161+
((thisPackage.dependencies && thisPackage.dependencies['sass']) ||
162+
(thisPackage.devDependencies && thisPackage.devDependencies['sass'])) &&
163+
!((thisPackage.dependencies && thisPackage.dependencies['node-sass']) ||
164+
(thisPackage.devDependencies && thisPackage.devDependencies['node-sass']))) {
165+
options['load-path'] = scssPaths;
166+
} else {
167+
options['include-path'] = scssPaths;
168+
}
162169

163170
var args = [];
164171

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--include-path node_modules/some-scss-lib/scss
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "should-not-use-sass-when-node-sass",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"keywords": [],
7+
"build": {
8+
"scssPaths": ["some-scss-lib/scss"]
9+
},
10+
"dependencies": {
11+
"node-sass": "^4.12.0",
12+
"some-scss-lib": "1.0.0",
13+
"sass": "^1.34.1"
14+
}
15+
}

test/plugins/scss/scss/should-not-use-sass-when-node-sass/require-all.scss

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--load-path node_modules/some-scss-lib/scss
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "should-use-sass-when-available",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"keywords": [],
7+
"build": {
8+
"scssPaths": ["some-scss-lib/scss"]
9+
},
10+
"dependencies": {
11+
"some-scss-lib": "1.0.0",
12+
"sass": "^1.34.1"
13+
}
14+
}

test/plugins/scss/scss/should-use-sass-when-available/require-all.scss

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--load-path node_modules/some-scss-lib/scss

0 commit comments

Comments
 (0)