Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use helmet * add e2e test * fix e2e test * add unit tests * add more e2e tests * update sw.js * run prod before ssg * get assets data from prod * fix npm scripts * clean up fixture * update description * clean up blank line * test cache busting * Revert "test cache busting" This reverts commit 9992136. * add more e2e tests * add more tests * fix test
- Loading branch information
Showing
17 changed files
with
1,687 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe('server side rendered page', () => { | ||
it('should find meta description', () => { | ||
cy.visit('/guides/getting-started/'); | ||
cy.get('head meta[name="description"]').should( | ||
'have.attr', | ||
'content', | ||
'Learn how to bundle a JavaScript application with webpack 5.' | ||
); | ||
}); | ||
|
||
it('should find html tag with lang', () => { | ||
cy.visit('/'); | ||
cy.get('html[lang="en"]'); | ||
}); | ||
|
||
it('should find meta charset', () => { | ||
cy.visit('/'); | ||
cy.get('meta[charset="utf-8"]'); | ||
}); | ||
|
||
it('should find the default meta description', () => { | ||
cy.visit('/'); | ||
cy.get('head meta[name="description"]').should( | ||
'have.attr', | ||
'content', | ||
'webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.' | ||
); | ||
}); | ||
|
||
it('should find title', () => { | ||
cy.visit('/'); | ||
cy.title().should('eq', 'webpack'); | ||
|
||
cy.visit('/guides/getting-started/'); | ||
cy.title().should('eq', 'Getting Started | webpack'); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Route } from 'react-router-dom'; | ||
import Site from './components/Site/Site'; | ||
export default function App() { | ||
return ( | ||
<Route | ||
path="/" | ||
render={(props) => ( | ||
<Site {...props} import={(path) => import(`./content/${path}`)} /> | ||
)} | ||
/> | ||
); | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { Compilation, sources } = require('webpack'); | ||
|
||
// collect assets data (vendor.[contenthash].js and index.[contenthash].js) for ssg | ||
class ProdAssetsManifest { | ||
apply(compiler) { | ||
let js = []; | ||
let css = []; | ||
compiler.hooks.thisCompilation.tap('ProdAssetsManifest', (compilation) => { | ||
compilation.hooks.processAssets.tap( | ||
{ | ||
name: 'ProdAssetsManifest', | ||
stage: Compilation.PROCESS_ASSETS_STAGE_ANALYSE, | ||
}, | ||
() => { | ||
for (const [, entrypoint] of compilation.entrypoints) { | ||
const files = entrypoint.getFiles(); | ||
js = js.concat( | ||
files | ||
.filter((file) => file.endsWith('.js')) // two js files | ||
.sort((a) => { | ||
// vendor first | ||
if (a.startsWith('vendor')) return -1; | ||
return 1; | ||
}) | ||
.map((file) => { | ||
return compilation.outputOptions.publicPath + file; | ||
}) | ||
); | ||
css = css.concat( | ||
files | ||
.filter((file) => file.endsWith('.css')) | ||
.sort((a) => { | ||
// index first | ||
if (a.startsWith('index')) return -1; | ||
return 1; | ||
}) | ||
.map((file) => compilation.outputOptions.publicPath + file) | ||
); | ||
} | ||
compilation.emitAsset( | ||
'prod-assets-manifest.json', | ||
new sources.RawSource(JSON.stringify({ js, css })) | ||
); | ||
} | ||
); | ||
}); | ||
} | ||
} | ||
module.exports = ProdAssetsManifest; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>webpack</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> | ||
</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
Oops, something went wrong.
d49899f
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.
Successfully deployed to the following URLs: