GithubHelp home page GithubHelp logo

blake-newman / grunt-wrap-commonjs Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 27 KB

Wrap CoffeeScript or JavaScript into a CommonJS compatible require definition

License: MIT License

CoffeeScript 94.87% JavaScript 5.13%

grunt-wrap-commonjs's Introduction

grunt-wrap-commonjs

Wraps .coffee and .js files into CommonJS modules for client-side usage.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-wrap-commonjs --save-dev

Then add this line to your project's Gruntfile.coffee:

grunt.loadNpmTasks 'grunt-wrap-commonjs'

CommonJS Require

You need a require.register function in the scope where you add the wrapped files. It's recommended to use commonjs-require for this purpose.

Documentation

Configure which files to be copied in your initConfig:

grunt.initConfig

  # ... other configs

  # wrap my modules with define
  commonjs:
    modules:
      cwd: 'assets/'
      src: ['**/*.coffee', '**/*.js']
      dest: 'dist/'

  # ... other configs

Configuration

pathReplace Allows you to set filterer function for module names, for example, change all app/file to file. Default: false

  pathReplace: (path) ->
    path.replace(/^app\//, '')

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

License

MIT

Copyright (c) 2013-2014 efa GmbH Copyright (c) 2012-2013 Christopher Rogers, Team Delicious, AVOS Systems Inc., Derek Petersen

grunt-wrap-commonjs's People

Contributors

chrisabrams avatar chrissrogers avatar tuxracer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.