-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add supports the
require
of CommonJS and JSON files in EJS te…
…mplates
- Loading branch information
Showing
18 changed files
with
226 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.74 KB
test/cases/_preprocessor/ejs-require-js/expected/assets/img/apple.02a7c382.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
test/cases/_preprocessor/ejs-require-js/expected/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Home</title> | ||
</head> | ||
<body> | ||
<h1>Breaking Bad</h1> | ||
<ul class="people"> | ||
|
||
<li>Walter White</li> | ||
|
||
<li>Jesse Pinkman</li> | ||
|
||
</ul> | ||
<img src="assets/img/apple.02a7c382.png" alt="apple" /> | ||
<div>footer</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
title: 'Home', | ||
headline: 'Breaking Bad', | ||
people: ['Walter White', 'Jesse Pinkman'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<% const data = require('./data.js') %> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title><%= data.title %></title> | ||
</head> | ||
<body> | ||
<h1><%= data.headline %></h1> | ||
<ul class="people"> | ||
<% for (let i = 0; i < data.people.length; i++) {%> | ||
<li><%= data.people[i] %></li> | ||
<% } %> | ||
</ul> | ||
<img src="@images/apple.png" alt="apple" /> | ||
<%- include('partials/footer.html'); %> | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/cases/_preprocessor/ejs-require-js/src/partials/footer.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div>footer</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const path = require('path'); | ||
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
resolve: { | ||
alias: { | ||
'@images': path.join(__dirname, '../../../fixtures/images'), | ||
}, | ||
}, | ||
|
||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
test: /\.(html|ejs)$/, | ||
entry: { | ||
index: { | ||
import: './src/home.ejs', | ||
}, | ||
}, | ||
preprocessor: 'ejs', | ||
}), | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(png|svg|jpe?g|webp)$/i, | ||
type: 'asset/resource', | ||
generator: { | ||
filename: 'assets/img/[name].[hash:8][ext]', | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
Binary file added
BIN
+1.74 KB
test/cases/_preprocessor/ejs-require-json/expected/assets/img/apple.02a7c382.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
test/cases/_preprocessor/ejs-require-json/expected/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Home</title> | ||
</head> | ||
<body> | ||
<h1>Breaking Bad</h1> | ||
<ul class="people"> | ||
|
||
<li>Walter White</li> | ||
|
||
<li>Jesse Pinkman</li> | ||
|
||
</ul> | ||
<img src="assets/img/apple.02a7c382.png" alt="apple" /> | ||
<div>footer</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"title": "Home", | ||
"headline": "Breaking Bad", | ||
"people": ["Walter White", "Jesse Pinkman"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<% const data = require('./data.json') %> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title><%= data.title %></title> | ||
</head> | ||
<body> | ||
<h1><%= data.headline %></h1> | ||
<ul class="people"> | ||
<% for (let i = 0; i < data.people.length; i++) {%> | ||
<li><%= data.people[i] %></li> | ||
<% } %> | ||
</ul> | ||
<img src="@images/apple.png" alt="apple" /> | ||
<%- include('partials/footer.html'); %> | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/cases/_preprocessor/ejs-require-json/src/partials/footer.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div>footer</div> |
40 changes: 40 additions & 0 deletions
40
test/cases/_preprocessor/ejs-require-json/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const path = require('path'); | ||
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
resolve: { | ||
alias: { | ||
'@images': path.join(__dirname, '../../../fixtures/images'), | ||
}, | ||
}, | ||
|
||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
test: /\.(html|ejs)$/, | ||
entry: { | ||
index: { | ||
import: './src/home.ejs', | ||
}, | ||
}, | ||
preprocessor: 'ejs', | ||
}), | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(png|svg|jpe?g|webp)$/i, | ||
type: 'asset/resource', | ||
generator: { | ||
filename: 'assets/img/[name].[hash:8][ext]', | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters