html-webpack-change-path-plugin
For html-webpack-change-path-plugin to change resource address,use in webpack 4 or higher
Install
npm i --save-dev html-webpack-change-path-plugin
yarn add --dev html-webpack-change-path-plugin
Options
Name | type | Description |
---|---|---|
configCSS | {Object} | {configCSS: {publicPath: "https://cdn.css.com/" }} |
configJS | {Object} | {configJS: {publicPath: "https://cdn.js.com/" }} |
Usage
Here's an example webpack config illustrating how to use these optionswebpack.config.js
const path = const MiniCssExtractPlugin = const HtmlWebpackPlugin = // const HtmlWebpackChangePathPlugin = require('../index')const HtmlWebpackChangePathPlugin = moduleexports = entry: index: './index.js' output: path: path filename: '[name].js' mode: 'production' module: rules: test: /.css$/ use: MiniCssExtractPluginloader 'css-loader' plugins: filename: '[name].css' template: path filename: 'index.html' chunks: 'index' inlineSource: '.css$' inject: true minify: html5: true collapseWhitespace: true preserveLineBreaks: false minifyCSS: true minifyJS: true removeComments: false configCSS: publicPath: 'https://cdn.css.com/' configJS: publicPath: 'https://cdn.js.com/'
This will generate a file dist/index.html
containing the following
Document