webpack-concat-plugin-with-optional-errors
raw JSON → 3.0.1 verified Sat Apr 25 auth: no javascript
Webpack plugin for concatenating files into a single output, with optional error throwing control. Version 3.0.1 requires Webpack ^4.0.1. Forked from webpack-concat-plugin, it adds the ability to suppress or enable errors during the concatenation process, giving developers flexibility in handling missing sources. The plugin supports configuration of source paths, output file, and error behavior. Ideal for custom builds where file concatenation is needed without hard failures.
Common errors
error Module not found: Error: Can't resolve 'webpack-concat-plugin-with-optional-errors' ↓
cause Package not installed or missing from node_modules.
fix
Run 'npm install webpack-concat-plugin-with-optional-errors --save-dev'
error TypeError: WebpackConcatPlugin is not a constructor ↓
cause Using wrong import style (e.g., destructured named export for default-only export).
fix
Use 'const WebpackConcatPlugin = require(...)' or 'import WebpackConcatPlugin from ...'
Warnings
gotcha If throwOnError is false, missing files will be silently ignored, potentially leading to unexpected output. ↓
fix Verify all source files exist or set throwOnError: true to get errors during build.
breaking Webpack 5 is not supported; peer dependency requires webpack ^4.0.1. ↓
fix Use webpack 4 or look for an updated version compatible with webpack 5.
Install
npm install webpack-concat-plugin-with-optional-errors yarn add webpack-concat-plugin-with-optional-errors pnpm add webpack-concat-plugin-with-optional-errors Imports
- default export wrong
const WebpackConcatPlugin = require('webpack-concat-plugin-with-optional-errors');correctimport WebpackConcatPlugin from 'webpack-concat-plugin-with-optional-errors'; - WebpackConcatPlugin (named)
import { WebpackConcatPlugin } from 'webpack-concat-plugin-with-optional-errors';
Quickstart
const WebpackConcatPlugin = require('webpack-concat-plugin-with-optional-errors');
module.exports = {
entry: './src/index.js',
output: {
path: __dirname + '/dist',
filename: 'bundle.js'
},
plugins: [
new WebpackConcatPlugin({
src: ['./src/header.js', './src/footer.js'],
dest: 'concatenated.js',
throwOnError: true
})
]
};