Skip to content

Instantly share code, notes, and snippets.

@nabigraphics
Created March 28, 2021 11:52
Show Gist options
  • Save nabigraphics/8bbc43164d734b1aa2874ac6774ceb57 to your computer and use it in GitHub Desktop.
Save nabigraphics/8bbc43164d734b1aa2874ac6774ceb57 to your computer and use it in GitHub Desktop.
React Fast Refresh 적용하기 - webpack.config.js
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