尝试更改网页包HtmlWebpackPlugin中的分隔符或使用自定义加载程序,但未成功
我一直在尝试更改HtmlWebpackPlugin ejs的分隔符,因为我需要能够输出我找到了它。您需要执行以下操作: 例1:尝试更改网页包HtmlWebpackPlugin中的分隔符或使用自定义加载程序,但未成功,webpack,ejs,html-webpack-plugin,Webpack,Ejs,Html Webpack Plugin,我一直在尝试更改HtmlWebpackPlugin ejs的分隔符,因为我需要能够输出我找到了它。您需要执行以下操作: 例1: 例2 例3 const path = require("path"); const common = require("./webpack.common"); const merge = require("webpack-merge"); const CleanWebpackPlugin =
例2
例3
const path = require("path");
const common = require("./webpack.common");
const merge = require("webpack-merge");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");
const WebpackShellPlugin = require('webpack-shell-plugin');
const { data } = require("jquery");
module.exports = merge(common, {
mode: "production",
output: {
filename: "[name].[contentHash].bundle.js",
path: path.resolve(__dirname, "dist")
},
optimization: {
minimizer: [
new OptimizeCssAssetsPlugin(),
new TerserPlugin(),
new HtmlWebpackPlugin({
template: "./src/template.html",
minify: {
removeAttributeQuotes: true,
collapseWhitespace: true,
removeComments: true
}
}),
new HtmlWebpackPlugin({
title: 'Custom template',
inject: false,
filename: 'test.aspx',
// interpolate : '\\{\\{(.+?)\\}\\}',
// evaluate : '\\[\\[(.+?)\\]\\]'
template: './src/templateasp.ejs',
// template: '!!ejs-loader!./src/templateasp.ejs'
}),
]
},
plugins: [
new MiniCssExtractPlugin({ filename: "[name].[contentHash].css" }),
new CleanWebpackPlugin(),
new WebpackShellPlugin({onBuildStart:['node "./prov/lists.build.node.mjs"'], onBuildEnd:['echo "Webpack End"']}),
],
module: {
rules: [
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader, //3. Extract css into files
"css-loader", //2. Turns css into commonjs
"sass-loader" //1. Turns sass into css
]
},
// {
// test: /\.ejs$/,
// loader: 'ejs-loader',
// options: {
// variable: 'data',
// interpolate : '\\{\\{(.+?)\\}\\}',
// evaluate : '\\[\\[(.+?)\\]\\]'
// }
// }
]
}
});
<%= '\<%-- _lcid="1033" _version="16.0.20113" _dal="1" --%\>' %>
<%= '\<%-- _LocalBinding --%\>' %>
<%= 'string text, use backslash to escape the delimiter as in \<% or %\>' %>