Skip to content

Commit

Permalink
webpack changes needed since we are working with CreateREactAppv2.x w…
Browse files Browse the repository at this point in the history
…hich produces a different Webpack file. need to make some modifications according to github.com/satendra02/react-chrome-extension/issues/2
  • Loading branch information
linnerissa committed May 29, 2021
1 parent 81e7914 commit a47b929
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,31 +169,28 @@ module.exports = function (webpackEnv) {
: isEnvDevelopment && "cheap-module-source-map",
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
entry:
isEnvDevelopment && !shouldUseReactRefresh
? [
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
//
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
//
// When using the experimental react-refresh integration,
// the webpack plugin takes care of injecting the dev client for us.
webpackDevClientEntry,
// Finally, this is your app's code:
paths.appIndexJs,
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
]
: paths.appIndexJs,
entry: {
app: [
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
isEnvDevelopment &&
require.resolve("react-dev-utils/webpackHotDevClient"),
// Finally, this is your app's code:
paths.appIndexJs,
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
].filter(Boolean),
content: path.appContent,
},
output: {
// The build folder.
path: isEnvProduction ? paths.appBuild : undefined,
Expand Down Expand Up @@ -297,16 +294,14 @@ module.exports = function (webpackEnv) {
// Automatically split vendor and commons
// https://twitter.com/wSokra/status/969633336732905474
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
splitChunks: {
chunks: "all",
name: isEnvDevelopment,
},
// splitChunks: {
// chunks: "all",
// name: isEnvDevelopment,
// },
// Keep the runtime chunk separated to enable long term caching
// https://twitter.com/wSokra/status/969679223278505985
// https://github.com/facebook/create-react-app/issues/5358
runtimeChunk: {
name: (entrypoint) => `runtime-${entrypoint.name}`,
},
runtimeChunk: false,
},
resolve: {
// This allows you to set a fallback for where webpack should look for modules.
Expand Down Expand Up @@ -564,7 +559,9 @@ module.exports = function (webpackEnv) {
{},
{
inject: true,
chunks: ["app"],
template: paths.appHtml,
filename: "popup.html",
},
isEnvProduction
? {
Expand Down Expand Up @@ -653,7 +650,7 @@ module.exports = function (webpackEnv) {
manifest[file.name] = file.path;
return manifest;
}, seed);
const entrypointFiles = entrypoints.main.filter(
const entrypointFiles = entrypoints.app.filter(
(fileName) => !fileName.endsWith(".map")
);

Expand Down

0 comments on commit a47b929

Please sign in to comment.