A webpack plugin that asserts the specified files are tree shaken
npm install -D webpack-assert-tree-shaking-plugin
yarn add -D webpack-assert-tree-shaking-plugin
In your webpack.config.js
,
const { WebpackAssertTreeShakingPlugin } = require('webpack-assert-tree-shaking-plugin');
module.exports = {
/* your configuration */
plugins: [
/* other plugins */
new WebpackAssertTreeShakingPlugin([
{
// Specify a module path that should be tree shaken
modulePath: A_FILE_PATH_TO_BE_TREE_SHAKEN,
},
{
modulePath: A_FILE_PATH_TO_BE_TREE_SHAKEN,
// You can also specify variable names that should be tree shaken
values: ['A_EXPORTED_VARIABLE_NAME_TO_BE_TREE_SHAKEN' /* ... */],
},
]),
],
};