Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
webpack-conditional-loader
Advanced tools
Inspired by C conditionals directive, conditional loader decides if a given block should be included in the final bundle.
Useful for removing instrumentation code and making your final production bundle smaller (therefore faster).
npm install --save-dev webpack-conditional-loader
webpack.config.js
Put webpack-conditional-loader
as the last loader in the array, so it will process the code before
all others.
module: {
rules: [{
test: /\.js$/,
use: ['babel-loader', 'webpack-conditional-loader']
}]
}
Get an example config file here
Use // #if expression
and // #endif
to wrap blocks of code you want to be removed if a given
predicate is false.
// #if process.env.NODE_ENV === 'DEVELOPMENT'
console.log('lorem')
console.log('ipsum')
// #endif
In the example above, the code will be removed if the enviroment variable NODE_ENV
is not
DEVELOPMENT
, removing unnecessary code from your production bundle.
The same technique can be used to prevent loading packages in the production bundle.
// #if process.env.NODE_ENV !== 'BUILD'
import reduxLogger from 'redux-logger'
// #endif
caiogondim.com · GitHub @caiogondim · Twitter @caio_gondim
FAQs
#ifdef for JavaScript
We found that webpack-conditional-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.