-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topics/regroup non static files #6346
Changes from 14 commits
4803d61
e1b8be9
77371b9
59cf18a
366bd97
972fb6b
4042ae1
695cb68
699e5ca
eed6616
d8a8377
87f0ada
cd834ab
414ce25
41f80b6
ef334d2
6f1e987
f1ad758
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
"__PATH_PREFIX__": false, | ||
"___emitter": false | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,8 @@ const createElement = React.createElement | |
|
||
export default (pagePath, callback) => { | ||
const pathPrefix = `${__PATH_PREFIX__}/` | ||
const pathToGroupStyles = `css/` | ||
const pathToGroupScripts = `js/` | ||
|
||
let bodyHtml = `` | ||
let headComponents = [] | ||
|
@@ -197,6 +199,7 @@ export default (pagePath, callback) => { | |
const scripts = scriptsAndStyles.filter( | ||
script => script.name && script.name.endsWith(`.js`) | ||
) | ||
|
||
const styles = scriptsAndStyles.filter( | ||
style => style.name && style.name.endsWith(`.css`) | ||
) | ||
|
@@ -225,7 +228,7 @@ export default (pagePath, callback) => { | |
as="script" | ||
rel={script.rel} | ||
key={script.name} | ||
href={urlJoin(pathPrefix, script.name)} | ||
href={urlJoin(pathPrefix, pathToGroupScripts, script.name)} | ||
/> | ||
) | ||
}) | ||
|
@@ -249,23 +252,23 @@ export default (pagePath, callback) => { | |
.forEach(style => { | ||
// Add <link>s for styles that should be prefetched | ||
// otherwise, inline as a <style> tag | ||
|
||
if (style.rel === `prefetch`) { | ||
headComponents.push( | ||
<link | ||
as="style" | ||
rel={style.rel} | ||
key={style.name} | ||
href={urlJoin(pathPrefix, style.name)} | ||
href={urlJoin(pathPrefix, pathToGroupStyles, style.name)} | ||
/> | ||
) | ||
} else { | ||
headComponents.unshift( | ||
<style | ||
data-href={urlJoin(pathPrefix, style.name)} | ||
type="text/css" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove this line? See #6384 |
||
data-href={urlJoin(pathPrefix, style.name.slice(2))} | ||
dangerouslySetInnerHTML={{ | ||
__html: fs.readFileSync( | ||
join(process.cwd(), `public`, style.name), | ||
join(process.cwd(), `public`, pathToGroupStyles, style.name), | ||
`utf-8` | ||
), | ||
}} | ||
|
@@ -294,7 +297,9 @@ export default (pagePath, callback) => { | |
// Filter out prefetched bundles as adding them as a script tag | ||
// would force high priority fetching. | ||
const bodyScripts = scripts.filter(s => s.rel !== `prefetch`).map(s => { | ||
const scriptPath = `${pathPrefix}${JSON.stringify(s.name).slice(1, -1)}` | ||
const scriptPath = `${pathPrefix}${pathToGroupScripts}${JSON.stringify( | ||
s.name | ||
).slice(1, -1)}` | ||
return <script key={scriptPath} src={scriptPath} async /> | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -435,8 +435,8 @@ module.exports = async ({ | |
*/ | ||
plugins.extractText = options => | ||
new MiniCssExtractPlugin({ | ||
filename: `[name].[contenthash].css`, | ||
chunkFilename: `[name].[contenthash].css`, | ||
filename: `../css/[name].[contenthash].css`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, the css is generated in the stage From what I could tell, there's no way of changing the output path (only publicPath?) using What's happening is the system things it's putting the CSS into the If there's a different way to handle this, such as creating |
||
chunkFilename: `../css/[name].[contenthash].css`, | ||
...options, | ||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#6346 (comment) @m-allanson removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍