Skip to content

Commit

Permalink
fix: make react-hot-dom alias working
Browse files Browse the repository at this point in the history
  • Loading branch information
serusko committed Mar 9, 2019
1 parent 41d8e30 commit 267905a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
26 changes: 13 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = {
overrideWebpackConfig: ({
webpackConfig,
pluginOptions,
context: {
env
}
Expand All @@ -10,7 +9,7 @@ module.exports = {
return webpackConfig;
}

const conf = { ...webpackConfig };
let conf = webpackConfig;

if (!conf || !conf.module || !conf.module.rules) {
return webpackConfig;
Expand All @@ -26,21 +25,22 @@ module.exports = {
}
}

return {
...conf,
resolve: {
...(conf.resolve || {}),
alias: {
...((conf.resolve && conf.resolve.alias) || {}),
'react-dom': '@hot-loader/react-dom'
}
}
};
return conf;
},

overrideCracoConfig: ({
cracoConfig
}) => {
if (!cracoConfig.webpack) {
cracoConfig.webpack = {};
}
if (!cracoConfig.webpack.alias) {
cracoConfig.webpack.alias = {};
}
const webpackAliases = cracoConfig.webpack.alias;

webpackAliases["react-dom"] = '@hot-loader/react-dom';

return {
...cracoConfig,
babel: {
Expand All @@ -50,6 +50,6 @@ module.exports = {
"react-hot-loader/babel"
]
}
};
};
}
};
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"repository": "https://github.com/HasanAyan/craco-plugin-react-hot-reload",
"author": "Hasan Ayan",
"license": "MIT",
"peerDependencies": {
"peer-dependencies": {
"@craco/craco": "^3.5.0",
"react-hot-loader": "^4.8.0"
"react-hot-loader": "^4.8.0",
"@hot-loader/react-dom": "^16.7.0"
}
}

0 comments on commit 267905a

Please sign in to comment.