Skip to content

Commit 06f94e0

Browse files
committed
update caching guidance
1 parent c19c274 commit 06f94e0

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

docs/quick/browser.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,38 @@ cd your-project
6565
"start": "webpack-dev-server -d --content-base ./public"
6666
},
6767
"dependencies": {
68-
"@types/react": "16.4.2",
69-
"@types/react-dom": "16.0.6",
70-
"react": "16.4.1",
71-
"react-dom": "16.4.1",
72-
"ts-loader": "4.4.1",
73-
"typescript": "2.9.2",
74-
"webpack": "4.12.1",
75-
"webpack-cli": "3.0.8",
76-
"webpack-dev-server": "3.1.4"
68+
"@types/react": "16.4.10",
69+
"@types/react-dom": "16.0.7",
70+
"clean-webpack-plugin": "0.1.19",
71+
"html-webpack-plugin": "3.2.0",
72+
"react": "16.4.2",
73+
"react-dom": "16.4.2",
74+
"ts-loader": "4.4.2",
75+
"typescript": "3.0.1",
76+
"webpack": "4.16.5",
77+
"webpack-cli": "3.1.0",
78+
"webpack-dev-server": "3.1.5"
7779
}
7880
}
7981
```
8082

8183
* Create a `webpack.config.js` to bundle your modules into a single `app.js` file that contains all your resources:
8284

8385
```js
86+
const CleanWebpackPlugin = require('clean-webpack-plugin');
87+
const HtmlWebpackPlugin = require('html-webpack-plugin');
88+
8489
module.exports = {
8590
entry: './src/app/app.tsx',
91+
plugins: [
92+
new CleanWebpackPlugin(['public/build']),
93+
new HtmlWebpackPlugin({
94+
template: 'src/templates/index.html'
95+
}),
96+
],
8697
output: {
8798
path: __dirname + '/public',
88-
filename: 'build/app.js'
99+
filename: 'build/[name].[contenthash].js'
89100
},
90101
resolve: {
91102
extensions: ['.ts', '.tsx', '.js']
@@ -98,15 +109,15 @@ module.exports = {
98109
}
99110
```
100111

101-
* `public/index.html` file that will be served from your webserver:
112+
* `src/templates/index.html` file. It will be used as the template for the `index.html` generated by webpack. The generated file will be in the `public` folder and and then served from your webserver:
102113

103114
```html
104115
<html>
105116
<body>
106117
<div id="root"></div>
107-
<script src="./build/app.js"></script>
108118
</body>
109119
</html>
120+
110121
```
111122

112123
* `src/app/app.tsx` that is your frontend application entry point:
@@ -132,10 +143,11 @@ ReactDOM.render(
132143

133144
# Develop your amazing application
134145

135-
> You can get the latest packages using `npm install typescript@latest react@latest react-dom@latest @types/react@latest @types/react-dom@latest webpack@latest ts-loader@latest webpack-dev-server@latest webpack-cli@latest --save-exact`
146+
> You can get the latest packages using `npm install typescript@latest react@latest react-dom@latest @types/react@latest @types/react-dom@latest webpack@latest webpack-dev-server@latest webpack-cli@latest ts-loader@latest clean-webpack-plugin@latest html-webpack-plugin@latest --save-exact`
136147
137148
* Do live development by running `npm start`.
138149
* Visit [http://localhost:8080](http://localhost:8080)
139-
* Edit the `app.tsx` (or any ts/tsx file in `src`) and application live reloads.
150+
* Edit the `src/app/app.tsx` (or any ts/tsx file used in some way by `src/app/app.tsx`) and application live reloads.
151+
* Edit the `src/templates/index.html` and the server live reloads.
140152
* Build production assets by running `npm run build`.
141153
* Serve the `public` folder (which contains the built assets) from your server.

0 commit comments

Comments
 (0)