-
-
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.
fix: if the same CSS file is imported in many js files, then the CSS …
…is extracted for the first issuer only, #68
- Loading branch information
Showing
20 changed files
with
185 additions
and
4 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
10 changes: 10 additions & 0 deletions
10
test/cases/js-import-css-nested-deep/expected/css/pageA.5b01e96e.css
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,10 @@ | ||
.bar { | ||
color: dodgerblue; | ||
background-color: white; | ||
border: 1px solid dodgerblue; | ||
} | ||
.foo { | ||
color: red; | ||
background-color: white; | ||
border: 1px solid red; | ||
} |
10 changes: 10 additions & 0 deletions
10
test/cases/js-import-css-nested-deep/expected/css/pageB.b78f128d.css
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,10 @@ | ||
.bar { | ||
color: dodgerblue; | ||
background-color: white; | ||
border: 1px solid dodgerblue; | ||
} | ||
.foo { | ||
color: red; | ||
background-color: white; | ||
border: 1px solid red; | ||
} |
1 change: 1 addition & 0 deletions
1
test/cases/js-import-css-nested-deep/expected/js/pageA.2fcc41eb.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 @@ | ||
(()=>{"use strict";console.log(">> Page A: ",{Foo:"Component Bar",Bar:"Component Foo"})})(); |
1 change: 1 addition & 0 deletions
1
test/cases/js-import-css-nested-deep/expected/js/pageB.af02ad73.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 @@ | ||
(()=>{"use strict";console.log(">> Page B: ",{Foo:"Component Bar",Bar:"Component Foo"})})(); |
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Page A</title> | ||
<link href="css/pageA.5b01e96e.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div style="display: flex; flex-direction: column;"> | ||
<h1>Page A</h1> | ||
<a href="pageB.html">Visit Page B</a> | ||
<b>Styled components:</b> | ||
<div class="bar">Foo</div> | ||
<div class="foo">Bar</div> | ||
</div> | ||
<script src="js/pageA.2fcc41eb.js"></script> | ||
</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,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Page B</title> | ||
<link href="css/pageB.b78f128d.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div style="display: flex; flex-direction: column;"> | ||
<h1>Page B</h1> | ||
<a href="pageA.html">Visit Page A</a> | ||
<b>Styled components:</b> | ||
<div class="bar">Foo</div> | ||
<div class="foo">Bar</div> | ||
</div> | ||
<script src="js/pageB.af02ad73.js"></script> | ||
</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 @@ | ||
.bar { | ||
color: dodgerblue; | ||
background-color: white; | ||
border: 1px solid dodgerblue; | ||
} |
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 @@ | ||
import './Bar.css'; | ||
|
||
const name = 'Component Bar'; | ||
|
||
export default name; |
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 @@ | ||
.foo { | ||
color: red; | ||
background-color: white; | ||
border: 1px solid 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,5 @@ | ||
import './Foo.css'; | ||
|
||
const name = 'Component Foo'; | ||
|
||
export default name; |
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: orangered; | ||
} |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Page A</title> | ||
</head> | ||
<body> | ||
<div style="display: flex; flex-direction: column;"> | ||
<h1>Page A</h1> | ||
<a href="pageB.html">Visit Page B</a> | ||
<b>Styled components:</b> | ||
<div class="bar">Foo</div> | ||
<div class="foo">Bar</div> | ||
</div> | ||
<script src="pageA.js"></script> | ||
</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,4 @@ | ||
import Foo from '../components/Bar'; | ||
import Bar from '../components/Foo'; | ||
|
||
console.log('>> Page A: ', { Foo, Bar }); |
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,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Page B</title> | ||
</head> | ||
<body> | ||
<div style="display: flex; flex-direction: column;"> | ||
<h1>Page B</h1> | ||
<a href="pageA.html">Visit Page A</a> | ||
<b>Styled components:</b> | ||
<div class="bar">Foo</div> | ||
<div class="foo">Bar</div> | ||
</div> | ||
<script src="pageB.js"></script> | ||
</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,4 @@ | ||
import Foo from '../components/Bar'; | ||
import Bar from '../components/Foo'; | ||
|
||
console.log('>> Page B: ', { Foo, Bar }); |
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,44 @@ | ||
const path = require('path'); | ||
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin'); | ||
|
||
// test: fix of the issue #68 | ||
|
||
module.exports = { | ||
mode: 'production', | ||
//mode: 'development', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
//entry: 'src/', | ||
entry: { | ||
pageA: './src/pages/pageA.html', | ||
pageB: './src/pages/pageB.html', | ||
}, | ||
|
||
js: { | ||
filename: 'js/[name].[contenthash:8].js', | ||
}, | ||
|
||
css: { | ||
filename: 'css/[name].[contenthash:8].css', | ||
}, | ||
}), | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(css)$/, | ||
use: ['css-loader'], | ||
}, | ||
], | ||
}, | ||
|
||
optimization: { | ||
usedExports: true, | ||
}, | ||
}; |
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