How to npm publish specific folder but as package root

后端 未结 10 1260
后悔当初
后悔当初 2020-12-13 01:10

I have a project that include a gulp task for building and packaging the sources and release in a directory called dist. My goal is publish it as a npm package,

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 01:49

    I highly recommend you to use .npmignore instead of moving or copying things around, specially if you are using a CI for deployments, and just add there the files you don't want to publish.

    https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package

    Example:

    #tests
    test
    coverage
    
    #build tools
    .travis.yml
    .jenkins.yml
    .codeclimate.yml
    
    #linters
    .jscsrc
    .jshintrc
    .eslintrc*
    
    #editor settings
    .idea
    .editorconfig
    

    Update:

    If you want to split your code, into different npm packages using the same repo, I bumped into this project recently: Lerna and looks really good.

    Maybe you should take a look

提交回复
热议问题