Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6ccb5f1

Browse files
author
Emile Frey
committed
simplifying hot module replacement in webpack config
1 parent 577d7c3 commit 6ccb5f1

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ __pycache__/
3737
.env.production.local
3838
package-lock.json
3939

40+
# Webpack output
41+
**/dist/*
42+
4043
npm-debug.log*
4144
yarn-debug.log*
4245
yarn-error.log*

‎frontend/.babelrc‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
"presets": [
33
"@babel/preset-env",
44
"@babel/preset-react"
5-
]
5+
],
6+
"plugins": [
7+
"@babel/plugin-syntax-dynamic-import",
8+
"@babel/plugin-proposal-class-properties"
9+
]
610
}

‎frontend/package.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
"author": "",
1212
"license": "ISC",
1313
"dependencies": {
14-
"@loadable/component": "^5.15.0",
1514
"@material-ui/core": "^4.11.0",
1615
"@material-ui/icons": "^4.9.1",
1716
"@material-ui/lab": "^4.0.0-alpha.57",
1817
"@testing-library/jest-dom": "^4.2.4",
1918
"@testing-library/react": "^9.3.2",
2019
"@testing-library/user-event": "^7.1.2",
2120
"axios": "^0.21.1",
22-
"http-server": "^0.12.3",
21+
"prop-types": "15.7.2",
2322
"react": "^17.0.1",
2423
"react-dom": "^17.0.1",
2524
"react-redux": "^7.2.1",
@@ -29,6 +28,8 @@
2928
},
3029
"devDependencies": {
3130
"@babel/core": "^7.14.6",
31+
"@babel/plugin-proposal-class-properties": "^7.12.13",
32+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
3233
"@babel/plugin-transform-runtime": "^7.14.5",
3334
"@babel/preset-env": "^7.14.7",
3435
"@babel/preset-react": "^7.14.5",
@@ -37,8 +38,10 @@
3738
"@types/react-redux": "^7.1.16",
3839
"@types/react-router-dom": "^5.1.7",
3940
"babel-loader": "^8.2.2",
41+
"css-loader": "^5.0.1",
4042
"html-webpack-plugin": "^5.3.2",
4143
"react-hot-loader": "^4.13.0",
44+
"style-loader": "^2.0.0",
4245
"ts-loader": "^8.2.0",
4346
"typescript": "^4.1.3",
4447
"webpack": "^5.42.0",

‎frontend/webpack.config.base.js‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const webpack = require("webpack");
21
const path = require("path");
32
const HtmlWebpackPlugin = require('html-webpack-plugin');
43

@@ -18,7 +17,29 @@ module.exports = {
1817
},
1918
{
2019
test: /\.css$/i,
21-
use: ['style-loader', 'css-loader'],
20+
use: [
21+
{
22+
loader: 'style-loader',
23+
options: {
24+
esModule: true,
25+
modules: {
26+
namedExport: true,
27+
},
28+
},
29+
},
30+
{
31+
loader: 'css-loader',
32+
options: {
33+
esModule: true,
34+
modules: {
35+
compileType: 'module',
36+
// mode: 'local',
37+
exportLocalsConvention: 'camelCaseOnly',
38+
namedExport: true,
39+
},
40+
},
41+
},
42+
]
2243
},
2344
{
2445
test: /\.(png|svg|jpg|jpeg|gif|ico)$/,
@@ -55,6 +76,5 @@ module.exports = {
5576
template: path.resolve(__dirname, "./index.html"),
5677
path: path.resolve(__dirname, "./dist"),
5778
favicon: path.resolve(__dirname, "./public/favicon.ico"),
58-
}),
59-
new webpack.HotModuleReplacementPlugin()]
79+
})]
6080
};

‎frontend/webpack.config.dev.js‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@ const webpack = require("webpack");
22
const path = require("path");
33
var config = require('./webpack.config.base.js')
44

5+
6+
config.entry = path.resolve(__dirname, "./src/index.js")
7+
58
config.devServer = {
69
host: '0.0.0.0',
710
disableHostCheck: true,
811
port: 3000,
912
contentBase: path.resolve(__dirname, "./dist"),
1013
hot: true,
1114
historyApiFallback: true,
12-
overlay: true
13-
},
14-
15+
inline: true,
16+
overlay: true,
17+
headers: {
18+
"Access-Control-Allow-Origin": "*",
19+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
20+
}
21+
}
1522

1623
config.plugins = config.plugins.concat([
24+
new webpack.HotModuleReplacementPlugin(),
1725
new webpack.DefinePlugin({
1826
'process.env.NODE_ENV': JSON.stringify('development')
1927
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /