Answer the question
In order to leave comments, you need to log in
What does html-weebpack-plugin complain about?
Hello! I can't figure out why webpack is complaining:
Error:
Html Webpack Plugin:
Error: Child compilation failed:
Module build failed (from ./node_modules/html-webpack-plugin/lib/loader.js):
SyntaxError: Invalid or unexpected token
- Function
- lodash.js:14870
[agromashina-master]/[lodash]/lodash.js:14870:16
- lodash.js:473 apply
[agromashina-master]/[lodash]/lodash.js:473:27
- lodash.js:15254
[agromashina-master]/[lodash]/lodash.js:15254:16
- lodash.js:475 apply
[agromashina-master]/[lodash]/lodash.js:475:27
- lodash.js:6563
[agromashina-master]/[lodash]/lodash.js:6563:16
- lodash.js:14869 Function.template
[agromashina-master]/[lodash]/lodash.js:14869:20
- SyntaxError: Invalid or unexpected token
- compiler.js:79 childCompiler.runAsChild
[agromashina-master]/[html-webpack-plugin]/lib/compiler.js:79:16
- Compiler.js:343 compile
[agromashina-master]/[webpack]/lib/Compiler.js:343:11
- Compiler.js:681 hooks.afterCompile.callAsync.err
[agromashina-master]/[webpack]/lib/Compiler.js:681:15
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[agromashina-master]/[tapable]/lib/Hook.js:154:20
- Compiler.js:678 compilation.seal.err
[agromashina-master]/[webpack]/lib/Compiler.js:678:31
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[agromashina-master]/[tapable]/lib/Hook.js:154:20
- Compilation.js:1423 hooks.optimizeAssets.callAsync.err
[agromashina-master]/[webpack]/lib/Compilation.js:1423:35
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[agromashina-master]/[tapable]/lib/Hook.js:154:20
- Compilation.js:1414 hooks.optimizeChunkAssets.callAsync.err
[agromashina-master]/[webpack]/lib/Compilation.js:1414:32
- Hook.js:154 AsyncSeriesHook.lazyCompileHook
[agromashina-master]/[tapable]/lib/Hook.js:154:20
- Compilation.js:1409 hooks.additionalAssets.callAsync.err
[agromashina-master]/[webpack]/lib/Compilation.js:1409:36
const autoprefixer = require('autoprefixer');
const path = require('path');
const HTMLPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
filename: 'js/bundle.js',
path: path.resolve(__dirname, 'dist')
},
optimization: {
minimizer: [
new OptimizeCssAssetsPlugin({}),
new UglifyJsPlugin({})
]
},
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
port: 4200
},
plugins: [
new HTMLPlugin({
filename: 'productend.html',
template: './src/productend.html'
}),
new HTMLPlugin({
filename: 'products.html',
template: './src/products.html'
}),
new HTMLPlugin({
filename: 'productend.html',
template: './src/productend.html'
}),
new HTMLPlugin({
filename: 'services.html',
template: './src/services.html'
}),
new MiniCssExtractPlugin({
filename: 'css/style.css'
})
],
resolve: {
extensions: ['.js', '.ts', '.css', '.less']
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']
},
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'less-loader']
},
{
test: /\.(js|ts)$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.(png|jpe?g|gif)$/i,
use:[
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath:'img',
publicPath:'/img/'
},
}
],
}
],
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question