npm の設定ファイル package.json は、 https://www.npmjs.org/doc/files/package.json.html で定義されているフィールドの他にも、 貴方好みの独自のフィールドを追加した状態で、 npm publish が可能です(単にエラーにならないという話です)。
たとえば、npm モジュールの雛形 Xxx.js の package.json では、 "build": { ... } フィールドを追加しています。
{
"name": "uupaa.xxx.js",
"version": "0.8.3",
"description": "",
"url": "https://github.com/uupaa/Xxx.js",
"keywords": ["Xxx", "util", "uupaa"],
"repository": {
"type": "git",
"url": "https://github.com/uupaa/Xxx.js.git"
},
"scripts": {
"watch": "node node_modules/uupaa.watch.js --verbose --action build ./lib/Xxx.js",
"build": "node node_modules/uupaa.minify.js --keep --output ./lib/Xxx.min.js ./lib/Xxx.js",
"test": "NODE_ENV=production NODE_PATH=lib node --harmony test/index.node.js; open test/index.html",
"lint": "plato --title Xxx.js --jshint .jshintrc -d lint/plato lib/Xxx.js; open lint/plato/index.html"
},
"build": { ←ここね
"all": {
"lib/Xxx.js": ""
},
"node": {
},
"worker": {
},
"browser": {
}
},
"dependencies": {
},
"devDependencies": {
"uupaa.help.js": "",
"uupaa.task.js": "",
"uupaa.test.js": "",
"uupaa.watch.js": "",
"uupaa.minify.js": ""
},
"lib": "./lib/",
"main": "./index.js",
"author": "uupaa <uupaa.js@gmail.com>",
"license": "MIT",
"contributors": []
}
Xxx.js では、各環境向けにビルドするファイルの一覧を "build": { ... } フィールドに列挙しておく。
といった使い方をしています。
jshintがこの技を使っていますよね。
jshintConfigがpackage.jsonにあったらそっちを使う(.jshintrcを無視する)というのでハマったことがあります。