@dpapejs/precompile-loader
v1.0.0
Published
A similar macro precompile loader for webpack
Downloads
1
Maintainers
Readme
A similar macro precompile loader for webpack
Install
npm i @dpapejs/precompile-loader -D
# OR
yarn add @dpapejs/precompile-loader -D
Webpack config
The default value is
false
if the configuration is not set
module.exports = {
...
module:{
rules:[
...,
{
test: /\.(jsx|js|vue)$/,
loader: "@dpapejs/precompile-loader",
options:{
config:{
user_modules:false,
logs_modules:true
}
}
}
]
}
...
}
Javascript code
// #if user_modules
console.log('user_modules')
// #endif user_modules
// #nif user_modules
console.log('is unif code -> user_modules')
// #endnif user_modules
// #if logs_modules
console.log('logs_modules')
// #endif logs_modules
Output the result after compilation
console.log('is unif code -> user_modules')
console.log('logs_modules')
Html code or template code
<!-- #if user_modules -->
<div>User module content</div>
<!-- #endif user_modules -->
<!-- #nif user_modules -->
<div>Unif User module content</div>
<!-- #endnif user_modules -->
<!-- #if logs_modules -->
<div>Logs module content</div>
<!-- #endif logs_modules -->
Output the result after compilation
<div>Unif User module content</div>
<div>Logs module content</div>