A browserify transformation loader for webpack.
This loader allows use of browserify transforms via a webpack loader.
To begin, you'll need to install transform-loader:
$ npm install transform-loader --save-devNote: We're using the coffeeify tranform for these examples.
Then invoke the loader through a require like so:
constthing=require('!transform-loader?coffeeify!widget/thing');Or add the loader to your webpack config. For example:
// entry.jsimportthingfrom'widget/thing';// webpack.config.jsmodule.exports={module: {rules: [{test: /\.coffee?$/,loader: `transform-loader?coffeeify`,// options: {...}},],},};And run webpack via your preferred method.
When using the loader via a require query string you may specify one of two
types; a loader name, or a function index.
Type: String
The name of the browserify transform you wish to use.
Note: You must install the correct transform manually. Webpack nor this loader will do that for you.
Type: Number
The index of a function contained within options.transforms which to use to
transform the target file(s).
Type: Array[Function]
Default: undefined
An array of functions that can be used to transform a given file matching the
configured loader test. For example:
// entry.jsconstthing=require('widget/thing');// webpack.config.jsconstthrough=require('through2');module.exports={module: {rules: [{test: /\.ext$/,// NOTE: we've specified an index of 0, which will use the `transform`// function in `transforms` below.loader: 'transform-loader?0',options: {transforms: [functiontransform(){returnthrough((buffer)=>{constresult=buffer.split('').map((chunk)=>String.fromCharCode(127-chunk.charCodeAt(0)));returnthis.queue(result).join('');},()=>this.queue(null));},],},},],},};Please take a moment to read our contributing guidelines if you haven't yet done so.