-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: resolve resource files in an attribute containing the JSON value
- Loading branch information
Showing
20 changed files
with
309 additions
and
45 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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test</title> | ||
<script src="js/main.bundle.js" defer="defer"></script> | ||
</head> | ||
<body> | ||
<h1>Hello World!</h1> | ||
|
||
<a id="test-elm" href="#" data-image='{ "alt":"picture", "imgSrc": "img/kiwi.da3e3cc9.png", "bgImage": { "imgSrc": "img/lemon.7b66be8e.png" } }'> | ||
<img src="img/image.697ef306.png" > | ||
</a> | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/cases/resolve-attr-json-require/expected/js/main.bundle.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test</title> | ||
<script src="./main.js" defer="defer"></script> | ||
</head> | ||
<body> | ||
<h1>Hello World!</h1> | ||
|
||
<a id="test-elm" href="#" data-image='{ "alt":"picture", "imgSrc": require("./kiwi.png"), "bgImage": { "imgSrc": require("./lemon.png") } }'> | ||
<img src="./image.png" > | ||
</a> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
const elm = document.getElementById('test-elm'); | ||
|
||
const value = elm.getAttribute('data-bigpicture'); | ||
const data = JSON.parse(value); | ||
|
||
console.log('>> main', { value }, data); |
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,3 @@ | ||
h1 { | ||
color: red; | ||
} |
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,57 @@ | ||
const path = require('path'); | ||
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
entry: { | ||
index: './src/index.html', | ||
}, | ||
|
||
js: { | ||
// output filename of extracted JS | ||
filename: 'js/[name].bundle.js', | ||
}, | ||
|
||
css: { | ||
// output filename of extracted CSS | ||
filename: 'css/[name].bundle.css', | ||
}, | ||
|
||
loaderOptions: { | ||
sources: [ | ||
{ | ||
tag: 'a', | ||
attributes: ['data-image'], | ||
filter: (obj) => { | ||
//console.log('### Filter: ', obj); | ||
}, | ||
}, | ||
], | ||
}, | ||
}), | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: ['css-loader'], | ||
}, | ||
|
||
{ | ||
test: /\.(png|jpe?g|ico|svg)$/, | ||
type: 'asset/resource', | ||
generator: { | ||
filename: 'img/[name].[hash:8][ext]', | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
Oops, something went wrong.