Всем привет.
webpack.config.js:
var path = require("path");
var HtmlWebpackPlugin = require('html-webpack-plugin');
// Plugins options array - BEGIN
var pluginsOptions = [];
// Plugins options array - END
// HtmlWebpackPlugin options - BEGIN
var titles = {
home: "iDea | Home",
shop: "iDea | Shop",
cart: "iDea | Cart"
};
for (var title in titles) {
pluginsOptions.push(
new HtmlWebpackPlugin({
title: titles[title],
template: `ejs-render!/${title}/${title}.ejs`,
chunks: [title],
filename: `${title}.html`
})
);
};
// HtmlWebpackPlugin options - END
module.exports = {
//context: __dirname + '/bundles',
context: path.join(__dirname, '/bundles'),
entry: {
home: './home/home.js',
shop: './shop/shop.js',
cart: './cart/cart.js'
},
output: {
path: path.resolve(__dirname, "www"),
filename: '[name].js'
},
watch: false,
module: {
rules: [
{
test: /\.js$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: {
presets: ['es2015']
}
}]
},
{
test: /\.ejs$/,
use: ['ejs-loader']
}
]
},
devServer: {
contentBase: path.join(__dirname, "www"),
compress: false,
port: 8080,
open: true
},
plugins: pluginsOptions
};
root:
-bundles
--home
---home.ejs
---logo.ejs
--shop
---shop.ejs
--cart
---cart.ejs
-www (output)
home.ejs:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestTitle</title>
</head>
<body>
<%- include logo.ejs %>
<hr>
<p>Custom content goes here.</p>
</body>
</html>
logo.ejs:
<div class="logo">Logo goes here.</div>
Ошибки:
ERROR in Error: Child compilation failed:
Entry module not found: Error: Can't resolve '/home/home.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles':
Error: Can't resolve '/home/home.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles'
ERROR in Error: Child compilation failed:
Entry module not found: Error: Can't resolve '/shop/shop.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles':
Error: Can't resolve '/shop/shop.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles'
ERROR in Error: Child compilation failed:
Entry module not found: Error: Can't resolve '/cart/cart.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles':
Error: Can't resolve '/cart/cart.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles'
Child html-webpack-plugin for "home.html":
ERROR in Entry module not found: Error: Can't resolve '/home/home.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles'
Child html-webpack-plugin for "shop.html":
ERROR in Entry module not found: Error: Can't resolve '/shop/shop.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles'
Child html-webpack-plugin for "cart.html":
ERROR in Entry module not found: Error: Can't resolve '/cart/cart.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles'
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "devw"
npm ERR! node v7.7.4
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! idea.test@1.0.0 devw: `npm run clean && webpack -d`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the idea.test@1.0.0 devw script 'npm run clean && webpack -d'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the idea.test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run clean && webpack -d
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs idea.test
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls idea.test
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\OpenServer\domains\test\idea.test\npm-debug.log
С чем связана эта ошибка и как ее исправить: "ERROR in Entry module not found: Error: Can't resolve '/home/home.ejs' in 'D:\OpenServer\domains\test\idea.test\bundles'"?
Народ, пожалуйста, помогите разобраться!