Skip to content

Commit

Permalink
Use the Node module resolution to figure out where to find modules #30
Browse files Browse the repository at this point in the history
  • Loading branch information
moonglum committed Nov 10, 2017
1 parent 58b7d69 commit bd3de27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

/samples/css.json
/samples/output/
/package-lock.json
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
node_js:
- 6
- 8
- 9

before_install:
- sudo apt-get -qq update
Expand Down
12 changes: 11 additions & 1 deletion lib/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ function translateBundlerConfigs(bundleConfigs, options) {
return bundleConfigs.map(bundleConfig => {
let inputFileName = path.resolve(configDir, bundleConfig.entryPoint);
let outputStyle = compact ? "compressed" : "nested";
let includePaths = [ path.resolve(configDir, "node_modules") ];
// Use the node dependency resolution algorithm to figure out the
// includePaths – only available in Node 8.9 and up
let includePaths;
if(require.resolve.paths) {
includePaths = require.resolve.paths("something");
} else {
includePaths = [ path.resolve(configDir, "node_modules") ];
console.warn("You are using Node.js < 8.9. We can " +
"therefore only offer a fallback implementation for importing " +
"Sass files from npm packages");
}
let target = bundleConfig.target;
let outputFilename = path.resolve(configDir, target);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "faucet-pipeline-sass",
"version": "0.7.1",
"version": "0.8.0",
"description": "Sass Asset Pipeline",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit bd3de27

Please sign in to comment.