A webpack plugin for converting external script files <script src="app.js"></script> to inline script block <script>...</script>. Requires html-webpack-plugin to work.
Inspired by react-dev-utils created by Facebook.
npm i html-inline-script-webpack-plugin -Dyarn add html-inline-script-webpack-plugin -Dnpm i html-inline-script-webpack-plugin@^1 -Dyarn add html-inline-script-webpack-plugin@^1 -DBy default, the plugin will convert all the external script files to inline script block.
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');
module.exports = {
plugins: [
new HtmlWebpackPlugin(),
new HtmlInlineScriptPlugin(),
]
}To limit the scope of the plugin, specify lists of files you wish to convert in regular expressions:
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');
module.exports = {
plugins: [
new HtmlWebpackPlugin(),
new HtmlInlineScriptPlugin([
/runtime~.+[.]js$/,
/app~.+[.]js$/
]),
]
}