-
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Linting issues, Add source reference to each config file
- Loading branch information
Showing
11 changed files
with
144 additions
and
148 deletions.
There are no files selected for viewing
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
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
8 changes: 4 additions & 4 deletions
8
lib/generators/react_on_rails/templates/base/base/app/javascript/packs/server-bundle.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import ReactOnRails from 'react-on-rails' | ||
import ReactOnRails from 'react-on-rails'; | ||
|
||
import HelloWorld from '../bundles/HelloWorld/components/HelloWorldServer' | ||
import HelloWorld from '../bundles/HelloWorld/components/HelloWorldServer'; | ||
|
||
// This is how react_on_rails can see the HelloWorld in the browser. | ||
ReactOnRails.register({ | ||
HelloWorld | ||
}) | ||
HelloWorld, | ||
}); |
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
15 changes: 9 additions & 6 deletions
15
lib/generators/react_on_rails/templates/base/base/config/webpack/clientWebpackConfig.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
const commonWebpackConfig = require('./commonWebpackConfig') | ||
// The source can be found at: | ||
// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/clientWebpackConfig.js | ||
|
||
const commonWebpackConfig = require('./commonWebpackConfig'); | ||
|
||
const configureClient = () => { | ||
const clientConfig = commonWebpackConfig() | ||
const clientConfig = commonWebpackConfig(); | ||
|
||
// server-bundle is special and should ONLY be built by the serverConfig | ||
// In case this entry is not deleted, a very strange "window" not found | ||
// error shows referring to window["webpackJsonp"]. That is because the | ||
// client config is going to try to load chunks. | ||
delete clientConfig.entry['server-bundle'] | ||
delete clientConfig.entry['server-bundle']; | ||
|
||
return clientConfig | ||
} | ||
return clientConfig; | ||
}; | ||
|
||
module.exports = configureClient | ||
module.exports = configureClient; |
15 changes: 9 additions & 6 deletions
15
lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
// The source can be found at: | ||
// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/commonWebpackConfig.js | ||
|
||
// Common configuration applying to client and server configuration | ||
|
||
const { webpackConfig: baseClientWebpackConfig, merge } = require('@rails/webpacker') | ||
const { webpackConfig: baseClientWebpackConfig, merge } = require('@rails/webpacker'); | ||
|
||
const commonOptions = { | ||
resolve: { | ||
extensions: ['.css', '.ts', '.tsx'] | ||
} | ||
} | ||
extensions: ['.css', '.ts', '.tsx'], | ||
}, | ||
}; | ||
|
||
// Copy the object using merge b/c the baseClientWebpackConfig and commonOptions are mutable globals | ||
const commonWebpackConfig = () => (merge({}, baseClientWebpackConfig, commonOptions)) | ||
const commonWebpackConfig = () => merge({}, baseClientWebpackConfig, commonOptions); | ||
|
||
module.exports = commonWebpackConfig | ||
module.exports = commonWebpackConfig; |
52 changes: 20 additions & 32 deletions
52
lib/generators/react_on_rails/templates/base/base/config/webpack/development.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,28 @@ | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'development' | ||
// The source code including full typescript support is available at: | ||
// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/development.js | ||
|
||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin') | ||
const path = require('path') | ||
const { devServer, inliningCss } = require('@rails/webpacker') | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'development'; | ||
|
||
const webpackConfig = require('./webpackConfig') | ||
const { devServer, inliningCss } = require('@rails/webpacker'); | ||
|
||
const developmentEnvOnly = (clientWebpackConfig, serverWebpackConfig) => { | ||
const webpackConfig = require('./webpackConfig'); | ||
|
||
const isWebpackDevServer = process.env.WEBPACK_DEV_SERVER | ||
const developmentEnvOnly = (clientWebpackConfig, _serverWebpackConfig) => { | ||
// eslint-disable-next-line no-unused-vars | ||
const isWebpackDevServer = process.env.WEBPACK_DEV_SERVER; | ||
|
||
//plugins | ||
if (inliningCss ) { | ||
// plugins | ||
if (inliningCss) { | ||
// Note, when this is run, we're building the server and client bundles in separate processes. | ||
// Thus, this plugin is not applied. | ||
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin') | ||
clientWebpackConfig.plugins.push( | ||
new ReactRefreshWebpackPlugin({ | ||
overlay:{ | ||
sockPort: devServer.port | ||
} | ||
}) | ||
) | ||
} | ||
|
||
// To support TypeScript type checker on a separate process uncomment the block below and add tsconfig.json | ||
// to the root directory. | ||
// As a reference visit https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/development.js | ||
|
||
// clientWebpackConfig.plugins.push( | ||
// new ForkTsCheckerWebpackPlugin({ | ||
// typescript: { | ||
// configFile: path.resolve(__dirname, '../../tsconfig.json') | ||
// }, | ||
// async: false | ||
// }) | ||
// ) | ||
} | ||
module.exports = webpackConfig(developmentEnvOnly) | ||
// eslint-disable-next-line global-require | ||
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); | ||
clientWebpackConfig.plugins.push(new ReactRefreshWebpackPlugin({ | ||
overlay: { | ||
sockPort: devServer.port, | ||
}, | ||
})); | ||
} | ||
}; | ||
module.exports = webpackConfig(developmentEnvOnly); |
13 changes: 7 additions & 6 deletions
13
lib/generators/react_on_rails/templates/base/base/config/webpack/production.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'production' | ||
// The source can be found at: | ||
// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/production.js | ||
|
||
// Below code should get refactored but the current way that rails/webpacker v5 | ||
// does the globals, it's tricky | ||
const webpackConfig = require('./webpackConfig') | ||
process.env.NODE_ENV = process.env.NODE_ENV || 'production'; | ||
|
||
const webpackConfig = require('./webpackConfig'); | ||
|
||
const productionEnvOnly = (_clientWebpackConfig, _serverWebpackConfig) => { | ||
// place any code here that is for production only | ||
} | ||
}; | ||
|
||
module.exports = webpackConfig(productionEnvOnly) | ||
module.exports = webpackConfig(productionEnvOnly); |
Oops, something went wrong.