2016-07-23 40 views
0

我目前有我的回购https://github.com/Aotik/Blossom,目前我正在处理此问题。这是一个NPM发布的包命名为blossom-ui安装我的NPM软件包时将文件移动到根目录

我的问题是,是否有安装包时出node_modules/blossom-ui的文件移动到外部文件夹node_modules根的方法吗?

因此,这将是这个样子

blossom-ui

  • css/

  • styl/

  • fonts/

  • js/

node_modules

  • ...
+0

“node_modules”目录的全部内容是*,这就是依赖关系去的地方。为什么你的软件包需要在其他地方? – jonrsharpe

+0

我想将已编译的文件(如CSS和JS)从node_modules移出,以便它们可以很容易地被定位到 –

+0

我仍然希望将源文件保存在'node_modules'中,以便我可以构建'build'脚本稍后的。 –

回答

0

如果使用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

0

这可以在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