A fork of webpack-concat-plugin that has the option to throw errors.
A plugin to help webpack concat js and inject into html
Webpack is really powerful. However, when I want to concat the static files and inject into html without webpack JSONP code wrapper, it seems impossible to do that without other tool's help.
I want to be able to throw errors when there's an error in the webpack-concat-plugin. Currently, it only logs an error. This allows a process to exit with 0, even if there's an error concatenating.
An example is if the webpack-concat-plugin attempts to concatenate es6 syntax, it will display a console error but exit successfully.
npm install webpack-concat-plugin-with-optional-errors --save-dev
yarn add webpack-concat-plugin-with-optional-errors --dev
- Concat
- Inject to html(with html-webpack-plugin)
const ConcatPlugin = require('webpack-concat-plugin');
new ConcatPlugin({
...see options
// examples
throwErrors: false, // set this to `true` to exit with 1 on errors
uglify: false,
sourceMap: false,
name: 'result',
outputPath: 'path/to/output/',
fileName: '[name].[hash:8].js',
filesToConcat: ['jquery', './src/lib/**', './dep/dep.js', ['./some/**', '!./some/excludes/**']],
attributes: {
async: true
}
});if an error is caught, this will exit with 1 rather than 0
if true the output file will be uglified
or set uglifyjs options to customize the output
if true, will output sourcemap
it's useful when you want to inject to html-webpack-plugin manully
if set, will be used as the public path of the script tag.
if set to false, will use relativePath.
if set, will be used as the output directory of the file.
if set, will be used as the output fileName
supported path patterns:
- normal path
- npm packages
- glob
how to auto inject to html-webpack-plugin(only if html-webpack-plugin set inject option not to be false)
if set, will be used as the extra attributes of the script tag.
doctype html
...
script(src=htmlWebpackPlugin.files.webpackConcat.flexible)
...