Skip to content

Commit c3e0fb6

Browse files
alcroitowawyed
authored andcommitted
Fix example to run with webpack 5
webpack serve should be used instead of webpack-dev-server starting with webpack 5. An explicit static directory ("/" in this case) needs to be specified to ensure the index.html file is found. The new webpack expects an explicit mode option. Set it to "development". Finally an extra leading slash is needed in output.publicPath to ensure the compiled js file is found. Amends 56539f6
1 parent 472d28e commit c3e0fb6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"license": "MIT",
33
"scripts": {
44
"prestart": "npx check-peer-dependencies --install",
5-
"start": "webpack-dev-server --open",
5+
"start": "webpack serve --open",
66
"prebuild": "npx check-peer-dependencies --install",
77
"build": "webpack",
88
"test": "npm run build && cypress-runner run --path .",

example/webpack.config.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@ module.exports = {
66
"app": "./src/main.ts",
77
},
88

9+
mode: 'development',
10+
911
devtool: 'cheap-module-source-map',
1012

1113
output: {
1214
path: path.join(__dirname, "_bundles"),
13-
publicPath: '_bundles/',
15+
publicPath: '/_bundles/',
1416
filename: "[name].js",
1517
},
1618

19+
devServer: {
20+
static: {
21+
directory: path.join(__dirname, '/')
22+
}
23+
},
24+
1725
resolve: {
1826
extensions: ['.js', '.ts']
1927
},

0 commit comments

Comments
 (0)