我怎么可以自定义这个节点生成脚本? [英] How can I customize this build script with Node?

查看:254
本文介绍了我怎么可以自定义这个节点生成脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我需要帮助做一个构建脚本独特的目录结构。结果
这里是链接(略有不同)或目录结构:

I have a unique directory structure that I need help making a build script for.
Here is the link (slightly different) or directory structure:

client
  /extensions
  /sandbox
  /widgets
    /form
      /collections
      /models
      /views
      /styles
        custom.css
      /controllers
  main.coffee
server
  /views
    /layouts
    /errors
  app.coffee
  config.coffee

夫妇的事情,我需要:

Couple things I need:


  • 编译CoffeeScript的一个手表任务到服务器 - 距离+
    客户端 - 距离

  • 所有其他文件拷贝过来到他们的嵌套的文件夹,$ P pferably与手表的任务也$

问题:


  • 如果我只是编译CoffeeScript的,它只是在.coffee文件的副本
    到.js文件到他们的嵌套目录但留下的CSS /
    IMGS /等装载require.js。我需要一种方法,使他们以及
    -dist 目录

  • Main.coffee在/客户端文件夹是一个require.config,可与requirejs使用咕噜构建工具来优化的事情。

反正最简单的解决方案是什么,我期待的。

Anyways the easiest solution is what I am looking for.

推荐答案

我最终使用咕噜 - 具有以下任务:

I ended up using grunt - with the following tasks:


  • 清洁:清除服务器/客户端生成目录

  • :显示器.coffee文件和双方建立目录

  • 复制:在客户端/服务器文件建立目录忽略.coffee文件,这是由咖啡任务管理副本

  • 咖啡:编译.coffee文件.js文件将它们移动到build目录

  • clean: Clears the server / client build directories
  • watch: Monitors .coffee files and both build directories
  • copy: Copies over client / server files to build directories ignoring .coffee files which are managed by the coffee task
  • coffee: Compiles .coffee files to .js moving them to the build directories

下面是在当前迭代咕噜文件:

Here is the grunt file in its current iteration:

grunt.initConfig({

 clean: {
   build: ['client-dist', 'server-dist'],
   release: []
 },

 watch: {
   coffee: {
     files: ['client/**/*.coffee', 'server/**/*.coffee'],
     tasks: 'coffee reload'
   },
   reload: {
     files: ['client/**/*.!(coffee)', 'server/**/*.!(coffee)'],
     tasks: 'copy reload'
   }
 },

 copy: {
   client: {
     files: {
       "client-dist/": "client/**/*.!(coffee)"
     },
     options: {
       basePath: "client"
     }
   },
   server: {
     files: {
       "server-dist/": "server/**/*.!(coffee)"
     },
     options: {
       basePath: "server"
     }
   }
 },

 coffee: {
   compile: {
     files: {
       'server-dist/*.js': 'server/**/*.coffee',
       'client-dist/*.js': 'client/**/*.coffee'
       }
     }
 }

});

grunt.loadNpmTasks('grunt-contrib');
grunt.loadNpmTasks('grunt-reload');

grunt.registerTask('default', '');
grunt.registerTask('build', 'clean:build copy coffee watch');

这篇关于我怎么可以自定义这个节点生成脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆