Skip to content

Instantly share code, notes, and snippets.

@ajmath
Last active May 13, 2019 23:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajmath/db7a1210cf9e01403e3dfb6004c1b89a to your computer and use it in GitHub Desktop.
Save ajmath/db7a1210cf9e01403e3dfb6004c1b89a to your computer and use it in GitHub Desktop.
serverless-plugin-typescript: Workaround for issue with excluding dev dependencies
package:
excludeDevDependencies: false
exclude: ${file(sls-exclude.js):get}
// @ts-nocheck
const childProcess = require("child_process");
const path = require("path");
const getDeps = (env) => {
const args = { encoding: "utf8" };
return childProcess.execSync(`npm ls --${env}=true --parseable=true --long=false --silent || true`, args).split("\n");
};
module.exports.get = () => {
const slsDir = path.resolve("./") + "/";
const prodDeps = getDeps("prod");
const devDeps = getDeps("dev");
const devFiles = devDeps.filter((d) => !prodDeps.includes(d)).map((d) => d.replace(slsDir, "") + "/**");
return [
...devFiles,
"yarn-error.log" // Add additional exclusions here
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment