package
transform loader for webpack
npm install transform-loaderGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Estimated unpacked size across 2 packages.
31.4 kB
Includes dependencies.
npm i transform-loader --savePass the module name as query parameter.
var x = require("!transform-loader?brfs!./file.js");
var x = require("!transform-loader/cacheable?brfs!./file.js"); // cacheable versionIf you pass a number instead it will take the function from this.options.transforms[number].
module.exports = {
module: {
rules: [
{
loader: "transform-loader?brfs",
enforce: "post"
},
{
test: /\.coffee$/,
loader: "transform-loader/cacheable?coffeeify"
},
{
test: /\.weirdjs$/,
loader: "transform-loader?0"
}
]
},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
transforms: [
function(file) {
return through(function(buf) {
module.exports = {
module: {
postLoaders: [
{
loader: "transform-loader?brfs"
}
]
loaders: [
{
test: /\.coffee$/,
loader: "transform-loader/cacheable?coffeeify"
},
{
test: /\.weirdjs$/,
loader: "transform-loader?0"
}
]
},
transforms: [
function(file) {
return through(function(buf) {
this.queue(buf.split("").map(function
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.
sokra
tobias.koppers@googlemail.com