ejs templating

This commit is contained in:
Ray Elliott 2021-01-03 21:30:11 +00:00
parent 690b014d4d
commit 8c1c474bd1
4 changed files with 14 additions and 8 deletions

View File

@ -23,11 +23,12 @@ Requirements
## NOT INCLUDED ## NOT INCLUDED
* code splitting * code splitting
#### html #### html
* html-webpack-plugin - automatically create index.html or use a template file * html-webpack-plugin - automatically create index.html or use a template file
also takes care of templating - default templating is ejs also takes care of templating - default templating is ejs
* ejs-compiled-loader (for use with the ejs templates)
bit of a fuck on getting it to work - [issue](https://github.com/bazilio91/ejs-compiled-loader/issues/46)
#### js #### js
@ -56,15 +57,12 @@ Requirements
* stylelint-webpack-plugin * stylelint-webpack-plugin
#### other #### other
* clean-webpack-plugin * clean-webpack-plugin
#### live server #### live server
* webpack-dev-server * webpack-dev-server
## Installation notes ## Installation notes
make repository private - edit package.json make repository private - edit package.json

View File

@ -19,7 +19,8 @@
</header> </header>
<main id="js-main"> <main id="js-main">
<%- include partials/component %> <% let data = {text: 'text is text'} %>
<%- include partials/component data %>
</main> </main>
<footer> <footer>

View File

@ -1,3 +1,3 @@
<div class="component"> <div class="component">
<p>sdklfj</p> <p><%= data.text %></p>
</div> </div>

View File

@ -26,11 +26,18 @@ module.exports = env => {
}), }),
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: '!!ejs-compiled-loader?{}!./src/templates/index.ejs' template: './src/templates/index.ejs'
}), }),
], ],
module: { module: {
rules: [ rules: [
{
test: /\.ejs$/,
use: {
loader: 'ejs-compiled-loader',
options: {}, // supply empty options object because of https://github.com/bazilio91/ejs-compiled-loader/issues/46
},
},
{ {
test: /\.js?/, test: /\.js?/,
exclude: /node_modules/, exclude: /node_modules/,