val-loader
val-loader
Executes the given module to generate source code on build time.
Install
npm install val-loader --save-dev
Examples
If you have a module findAnswer.js
like this:
function findAnswer() { return { code: 'module.exports = 42;' }; } module.exports = findAnswer;
you can use the val-loader to generate source code on build time:
// webpack.config.js module.exports = { ... module: { rules: [{ test: require.resolve('path/to/findAnswer.js'), use: [{ loader: 'val-loader' }] }] } };
A complete example of all available features looks like this:
const ask = require('./ask.js'); const generateResult = require('./generat