это мой webpack.config.js
const path = require("path");
//const merge = require("webpack-merge");
const htmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const htmlInlineCssPlugin = require("html-inline-css-webpack-plugin").default;
const htmlInlineSourcePlugin = require("html-webpack-inline-source-plugin");
var serverConfig = {
entry: "./src/server.js",
output: {
path: path.join(__dirname,'/bundle'),
filename: "server_bundle.js"
},
"target": "node",
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node-modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.hbs$/,
use: {
loader: "handlebars-loader"
}
}
]
},
devtool: "source-map",
plugins: [
new htmlWebpackPlugin({
inlineSource: '.(js|css)$'
}),
new htmlInlineSourcePlugin(),
]
}
module.exports = serverConfig;
это мой server.js
let express = require("express");
let app = express();
//let Email = require("email-templates");
let path = require('path');
app.get("/getHandleBar",function(req,res){
var a = require( path.join(__dirname,"helpers","abc.hbs"));
res.send(a());
console.log(a());
})
app.listen(3000,function(){
console.log("app is listening on port 3000");
})
, когда я получаю доступ к http://localhost:3000/getHandleBar, получаяследующая ошибка .. На самом деле я пытаюсь получить скомпилированные шаблоны электронной почты динамически с помощью веб-пакета.
SyntaxError: Unexpected token <
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at D:\nodeapp\src\server.js:39:13
at Layer.handle [as handle_request] (D:\nodeapp\node_modules\express\lib\router\layer.js:95:5)
at next (D:\nodeapp\node_modules\express\lib\router\route.js:137:13)
Мой руль
<html>
<head>
{{!-- <link rel="stylesheet" type="text/css" href="/helpers/abc.css"></link> --}}
</head>
<body>
<div>This is a</div>
</body>
</html>
Также это моя структура папок: пожалуйста, обратитесьснимок экрана введите описание изображения здесь