Webpack loader uses preprocess to preprocess HTML, Javascript, and other module files based on custom or environment configurations.
Inspired by gulp-preprocess and coffee-loader.
This loader is used within loader-chain before other loaders doing 'real' job.
var exports = require('coffee!preprocess?+DEBUG&NODE_ENV=production!./file.coffee')
{
module: {
loaders: [{
test: /\.coffee$/
loader: 'coffee!preprocess?+DEBUG&NODE_ENV=production'
}]
}
}
<head>
<title>Your App
<!-- @if NODE_ENV='production' -->
<script src="some/production/lib/like/analytics.js"></script>
<!-- @endif -->
</head>
<body>
<!-- @ifdef DEBUG -->
<h1>Debugging mode - <!-- @echo RELEASE_TAG --> </h1>
<!-- @endif -->
<p>
<!-- @include welcome_message.txt -->
</p>
</body>
var configValue = '/* @echo FOO */' || 'default value';
// @ifdef DEBUG
someDebuggingCall()
// @endif
configValue = '/* @echo FOO */' or 'default value'
# @ifdef DEBUG
somDebuggingCall()
# @endif
More examples can be found in README of preprocess.
MIT