Skip to content

Commit

Permalink
feat(bootstrap): adds support for resolving bootstrap scss
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalankey committed Apr 6, 2018
1 parent 8e57640 commit 61bddbd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
36 changes: 22 additions & 14 deletions plugins/scss/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ const utils = require('../../utils');
var directories = {};
var scssPaths = [];
var scssEntries = [];
var compassPath = null;
var basePackage = null;

var scssShortcuts = {
'compass-mixins': 'compass-mixins/lib',
'bootstrap': 'bootstrap/scss'
};

const resolver = function(pack, projectDir, depth) {
basePackage = basePackage || pack;

Expand All @@ -23,19 +27,24 @@ const resolver = function(pack, projectDir, depth) {

directories[pack.name] = projectDir;

if (!compassPath && pack.dependencies &&
pack.dependencies['compass-mixins']) {
// try to resolve compass by walking node_modules
compassPath = utils.resolveModulePath('compass-mixins/lib', projectDir);

if (!compassPath) {
// resolve the path from the project directory if not found in node_modules
compassPath = utils.flattenPath(path.resolve(
projectDir, 'node_modules/compass-mixins/lib'));
if (pack.dependencies) {
for (var dep in pack.dependencies) {
var shortcut = scssShortcuts[dep];
if (shortcut) {
// try to resolve the path by walking node_modules
var scssPath = utils.resolveModulePath(shortcut, projectDir);

if (!scssPath) {
// resolve the path from the project directory if not found in node_modules
scssPath = utils.flattenPath(path.resolve(projectDir, 'node_modules/' + shortcut));
}

if (scssPath) {
console.log(dep + ' resolved to ' + scssPath);
scssPaths.push(scssPath);
}
}
}

console.log('Compass resolved to ' + compassPath);
scssPaths.push(compassPath);
}

if (pack.directories && pack.directories.scss) {
Expand Down Expand Up @@ -162,7 +171,6 @@ const clear = function() {
directories = {};
scssPaths = [];
scssEntries = [];
compassPath = null;
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--include-path node_modules/bootstrap/scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "should-find-bootstrap-dependency",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"dependencies": {
"bootstrap": "=4.0.0"
}
}
Empty file.

0 comments on commit 61bddbd

Please sign in to comment.