Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
feat(sass): add conditional sass deps for webpack (#355)
Browse files Browse the repository at this point in the history
Add sass dependency only if the dev-sass plugin is already installed.
  • Loading branch information
MartoYankov authored and Vasil Chimev committed Dec 18, 2017
1 parent 0b9febe commit f51241c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dependencyManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { isAngular, isTypeScript } = require("./projectHelpers");
const { isAngular, isTypeScript, isSass } = require("./projectHelpers");

const NEW_DEPS_MESSAGE = `\
A few new dependencies were added. \
Expand Down Expand Up @@ -76,6 +76,10 @@ function getRequiredDeps(packageJson) {
Object.assign(deps, { "awesome-typescript-loader": "~3.1.3" });
}

if (isSass({packageJson})) {
Object.assign(deps, { "sass-loader": "~6.0.6" });
}

return deps;
}

Expand Down
13 changes: 13 additions & 0 deletions projectHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ const isAngular = ({ projectDir, packageJson } = {}) => {
.some(dependency => /^@angular\b/.test(dependency));
};

const isSass = ({ projectDir, packageJson } = {}) => {
packageJson = packageJson || getPackageJson(projectDir);

return (
packageJson.dependencies &&
packageJson.dependencies.hasOwnProperty("nativescript-dev-sass")
) || (
packageJson.devDependencies &&
packageJson.devDependencies.hasOwnProperty("nativescript-dev-sass")
);
};

const getAndroidRuntimeVersion = (projectDir) => {
try {
const projectPackageJSON = getPackageJson(projectDir);
Expand Down Expand Up @@ -105,6 +117,7 @@ const getPackageJsonPath = projectDir => path.resolve(projectDir, "package.json"
module.exports = {
isTypeScript,
isAngular,
isSass,
writePackageJson,
getPackageJson,
getProjectDir,
Expand Down

0 comments on commit f51241c

Please sign in to comment.