我目前有我的回購https://github.com/Aotik/Blossom,目前我正在處理此問題。這是一個NPM發佈的包命名爲blossom-ui
安裝我的NPM軟件包時將文件移動到根目錄
我的問題是,是否有安裝包時出node_modules/blossom-ui
的文件移動到外部文件夾node_modules
根的方法嗎?
因此,這將是這個樣子
blossom-ui
css
/styl
/fonts
/js
/
node_modules
...
我目前有我的回購https://github.com/Aotik/Blossom,目前我正在處理此問題。這是一個NPM發佈的包命名爲blossom-ui
安裝我的NPM軟件包時將文件移動到根目錄
我的問題是,是否有安裝包時出node_modules/blossom-ui
的文件移動到外部文件夾node_modules
根的方法嗎?
因此,這將是這個樣子
blossom-ui
css
/
styl
/
fonts
/
js
/
node_modules
...
如果使用grunt
,一個簡單的任務copy將使它像這樣:
copy: {
vendor: {
files: [{
expand: true,
cwd: 'node_modules/bootstrap/',
src: ['js/**', 'less/**'],
dest: 'public/vendor/bootstrap/'
}]
}
}
.....
grunt.registerTask('build', ['copy:vendor']);
例如Drywall project使用它將引導&骨幹複製到像上面那樣的/public/vendor
。如果您檢查其gruntfile.js。
請記住,如果你從node_modules
這可以在postinstall
腳本來完成在NPM複製目標文件夾必須存在於你的.gitignore
。
postinstall
由npm自動執行,每次npm install
完成。
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "cp node_modules/blossom-ui ."
},
更多信息:npm site scripts page。
「node_modules」目錄的全部內容是*,這就是依賴關係去的地方。爲什麼你的軟件包需要在其他地方? – jonrsharpe
我想將已編譯的文件(如CSS和JS)從node_modules移出,以便它們可以很容易地被定位到 –
我仍然希望將源文件保存在'node_modules'中,以便我可以構建'build'腳本稍後的。 –