Skip to content

Commit

Permalink
feat: add fast refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderdrummer committed Dec 21, 2020
1 parent 7a6145c commit a44b60b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions apps/the-app/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const nrwlConfig = require("@nrwl/react/plugins/webpack.js");
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
const webpack = require("webpack");

const { NX_ENV } = process.env;
Expand All @@ -8,11 +9,27 @@ const isDevelopment = NX_ENV === "development";
module.exports = (config, _) => {
nrwlConfig(config);

if (isDevelopment) {
//fast refresh
config.module.rules[0] = {
test: /\.([jt])sx?$/,
loader: "babel-loader",
exclude: /node_modules/,
options: {
babelrc: true,
cacheDirectory: true,
cacheCompression: false,
plugins: ["react-refresh/babel"],
},
};
}

return {
...config,
plugins: [
...config.plugins,
isDevelopment && new webpack.HotModuleReplacementPlugin(),
isDevelopment && new ReactRefreshWebpackPlugin(),
].filter(Boolean),
devServer: {
...config.devServer,
Expand Down

0 comments on commit a44b60b

Please sign in to comment.