我目前有我的回购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'脚本稍后的。 –