File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 11const devBuild = process . env . NODE_ENV === 'development' ;
22const isHMR = process . env . WEBPACK_DEV_SERVER === 'TRUE' ;
33const ReactRefreshWebpackPlugin = require ( '@pmmmwh/react-refresh-webpack-plugin' ) ;
4- const webpack = require ( 'webpack ' ) ;
4+ const { config } = require ( 'shakapacker ' ) ;
55const environment = require ( './environment' ) ;
66
7+ // Auto-detect bundler from shakapacker config and load the appropriate library
8+ const bundler = config . assets_bundler === 'rspack'
9+ ? require ( '@rspack/core' )
10+ : require ( 'webpack' ) ;
11+
712if ( devBuild && ! isHMR ) {
813 environment . loaders . get ( 'sass' ) . use . find ( ( item ) => item . loader === 'sass-loader' ) . options . sourceMap = false ;
914}
1015
1116environment . plugins . append (
1217 'Provide' ,
13- new webpack . ProvidePlugin ( {
18+ new bundler . ProvidePlugin ( {
1419 $ : 'jquery' ,
1520 jQuery : 'jquery' ,
1621 jquery : 'jquery' ,
Original file line number Diff line number Diff line change 11// The source code including full typescript support is available at:
22// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/clientWebpackConfig.js
33
4- const webpack = require ( 'webpack ' ) ;
4+ const { config } = require ( 'shakapacker ' ) ;
55const commonWebpackConfig = require ( './commonWebpackConfig' ) ;
66
7+ // Auto-detect bundler from shakapacker config and load the appropriate library
8+ const bundler = config . assets_bundler === 'rspack'
9+ ? require ( '@rspack/core' )
10+ : require ( 'webpack' ) ;
11+
712const configureClient = ( ) => {
813 const clientConfig = commonWebpackConfig ( ) ;
914
1015 clientConfig . plugins . push (
11- new webpack . ProvidePlugin ( {
16+ new bundler . ProvidePlugin ( {
1217 $ : 'jquery' ,
1318 jQuery : 'jquery' ,
1419 ActionCable : '@rails/actioncable' ,
Original file line number Diff line number Diff line change 11const merge = require ( 'webpack-merge' ) ;
22
33const devBuild = process . env . NODE_ENV === 'production' ? 'production' : 'development' ;
4- const webpack = require ( 'webpack' ) ;
5-
4+ const { config } = require ( 'shakapacker' ) ;
65const environment = require ( './environment' ) ;
76
7+ // Auto-detect bundler from shakapacker config and load the appropriate library
8+ const bundler = config . assets_bundler === 'rspack'
9+ ? require ( '@rspack/core' )
10+ : require ( 'webpack' ) ;
11+
812// React Server Side Rendering shakapacker config
913// Builds a Node compatible file that React on Rails can load, never served to the client.
1014
1115environment . plugins . insert (
1216 'DefinePlugin' ,
13- new webpack . DefinePlugin ( {
17+ new bundler . DefinePlugin ( {
1418 TRACE_TURBOLINKS : true ,
1519 'process.env' : {
1620 NODE_ENV : devBuild ,
You can’t perform that action at this time.
0 commit comments