@sliv/webpack-dynamic-script-loader
v0.0.1
Published
a loader for runtime dynamic script.
Downloads
18
Readme
webpack-dynamic-script-loader
a loader for runtime dynamic script.
usage
let config = {
module: {
rules: [
{
test: /\.dynamic.js/,
enforce: 'pre',
loaders: ['@sliv/webpack-dynamic-script-loader']
}
]
}
}
// time.dynamic.js
// notice the require is webpack's require not node's
// use req if you need to access nodeRequire
module.exports = (req) => {
let os = req('os')
let runtimeScript = `module.exports = "this machine have ${os.cpus().length} cpu"`
return runtimeScript
}