GithubHelp home page GithubHelp logo

anthrax3 / transform-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webpack-contrib/transform-loader

0.0 1.0 0.0 142 KB

transform loader for webpack

License: MIT License

JavaScript 100.00%

transform-loader's Introduction

npm deps chat

Transform Loader

Use browserify transforms as webpack-loader.

Install

npm i transform-loader --save

Pass the module name as query parameter.

var x = require("!transform-loader?brfs!./file.js");

If you pass a number instead it will take the function from this.options.transforms[number].

webpack 2 config example

module.exports = {
  module: {
    rules: [
      {
        loader: "transform-loader?brfs",
        enforce: "post",
        options: {
          transforms: [
              function (/*file*/) {
                  return through((buffer) => {
                      return this.queue(
                          buffer.split('')
                              .map((chunk) => String.fromCharCode(127-chunk.charCodeAt(0))))
                              .join('')
                  }, () => this.queue(null))
              }
          ]
        }
      },

      {
        test: /\.weirdjs$/,
        loader: "transform-loader?0",
        options: {
          transforms: [
              function (/*file*/) {
                  return through((buffer) => {
                      return this.queue(
                          buffer.split('')
                              .map((chunk) => String.fromCharCode(127-chunk.charCodeAt(0))))
                              .join('')
                  }, () => this.queue(null))
              }
          ]
        }
      }
    ]
  }
};

Typical brfs Example

Say you have the following Node source:

var test = require('fs').readFileSync('./test.txt', 'utf8');

After npm install transform-loader brfs --save, add the following loader to your config:

module.exports = {
    context: __dirname,
    entry: "./index.js",
    module: {
        loaders: [
            {
                test: /\.js$/,
                loader: "transform-loader?brfs"
            }
        ]
    }
}

The loader is applied to all JS files, which can incur a performance hit with watch tasks. So you may want to use transform-loader/cacheable?brfs instead.

Maintainers


Juho Vepsäläinen

Joshua Wiens

Kees Kluskens

Sean Larkin

transform-loader's People

Contributors

jgoz avatar joshwiens avatar kevinzwhuang avatar mattdesl avatar nicholascloud avatar niksy avatar prithvirajbilla avatar ryantd avatar simon04 avatar sokra 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.