Created
March 28, 2021 11:52
-
-
Save nabigraphics/8bbc43164d734b1aa2874ac6774ceb57 to your computer and use it in GitHub Desktop.
React Fast Refresh 적용하기 - webpack.config.js
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
const path = require("path"); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin"); | |
const isDevelopment = process.env.NODE_ENV !== "production"; | |
module.exports = () => { | |
return { | |
mode: isDevelopment ? "development" : "production", | |
entry: { app: "./src/index.tsx" }, | |
output: { path: path.resolve(__dirname, "./dist") }, | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx$/, | |
exclude: /node_modules/, | |
use: { | |
loader: "babel-loader", | |
options: { | |
plugins: [isDevelopment && "react-refresh/babel"].filter(Boolean), | |
}, | |
}, | |
}, | |
], | |
}, | |
resolve: { extensions: [".ts", ".tsx", ".js"] }, | |
devServer: { | |
hot: true, | |
port: 9000, | |
}, | |
plugins: [ | |
isDevelopment && new ReactRefreshWebpackPlugin(), | |
new HtmlWebpackPlugin({ | |
template: "./src/index.html", | |
}), | |
].filter(Boolean), | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment