LoginSignup
5
7

More than 5 years have passed since last update.

serverlessでデプロイパッケージからディレクトリごとをexcludeする

Last updated at Posted at 2016-10-14

serverlessで作成したデプロイパッケージを確認したところ、.gitがexcludeされてなかったので設定されるようにしました。

実行環境

$ uname -a
Darwin xxxxxx 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64
$ node -v
v6.7.0
$ serverless -v
1.0.2
$ cat /usr/local/lib/node_modules/serverless/node_modules/glob/package.json | grep '"version"'
  "version": "7.1.0"

デフォルトのexclude設定

デフォルトの設定を確認した限りではexcludeしてくれそうに見えます。

[
  '.git',
  '.gitignore',
  '.DS_Store',
  'npm-debug.log',
  'serverless.yaml',
  'serverless.yml',
  '.serverless',
]

必要な設定

package:
  exclude:
    - .git/**

原因のコード

アーカイブするファイル一覧を作っている場所は以下です。

      const files = glob.sync('**', {
        cwd: servicePath,
        ignore: exclude,
        dot: true,
        silent: true,
      });

globの要求されている動作を調べていないのでわかりませんが、元の設定で除外してくれたほうが嬉しいですね。
時間があれば週末に調べて修正してpull request出したいと思います。

おまけ

ついでにいらなそうなファイルもexcludeして以下のような設定になりました。

package:
  exclude:
    - .git/**
    - test
    - test/**
    - node_modules/.bin
    - node_modules/.bin/*
    - node_modules/aws-sdk
    - node_modules/aws-sdk/**
    - event.json
    - README.md
5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7