本文介绍了如何发布带有分发文件的npm软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想发布一个npm软件包,其中包含我的源代码和分发文件.我的Github存储库包含 src 文件夹,其中包含JavaScript源文件.构建过程将生成包含分发文件的 dist 文件夹.当然, dist 文件夹不会签入Github存储库.

I would like to publish a npm package that contains my source as well as distribution files. My Github repository contains src folder which contains JavaScript source files. The build process generates dist folder that contains the distribution files. Of course, the dist folder is not checked into the Github repository.

我如何发布npm软件包,以便当有人进行 npm安装时,他们会得到 src dist 文件夹?目前,当我从git存储库中运行 npm publish 时,只会导致发布 src 文件夹.

How do I publish a npm package in a way that when someone does npm install, they get src as well as dist folder? Currently when I run npm publish from my git repository, it results in only src folder being published.

我的package.json看起来像这样:

My package.json looks like this:

{
  "name": "join-js",
  "version": "0.0.1",
  "homepage": "https://github.com/archfirst/joinjs",
  "repository": {
    "type": "git",
    "url": "https://github.com/archfirst/joinjs.git"
  },
  "main": "dist/index.js",
  "scripts": {
    "test": "gulp",
    "build": "gulp build",
    "prepublish": "npm run build"
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    ...
  }
}

推荐答案

看看package.json文件的文件"字段 https://docs.npmjs.com/files/package.json#files

Take a look at the "files" field of package.json filehttps://docs.npmjs.com/files/package.json#files

从文档中:

这篇关于如何发布带有分发文件的npm软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 12:07