File tree 15 files changed +136
-279
lines changed 15 files changed +136
-279
lines changed Original file line number Diff line number Diff line change 19
19
steps :
20
20
- uses : actions/checkout@v3
21
21
- uses : actions/setup-node@v3
22
+ - run : npm -g install yalc
23
+ - run : yalc publish
24
+ - run : cd test/dummy_shakapacker && yalc add react_ujs
25
+ - run : cd test/dummy_shakapacker && yarn
22
26
- uses : ruby/setup-ruby@v1
23
27
with :
24
28
ruby-version : 2.7.3
Original file line number Diff line number Diff line change @@ -7,3 +7,5 @@ test/*/public/packs
7
7
** /node_modules
8
8
react-builds /build
9
9
coverage /
10
+ ** /.yalc
11
+ ** /yalc. *
Original file line number Diff line number Diff line change @@ -70,14 +70,14 @@ namespace :ujs do
70
70
end
71
71
end
72
72
73
- require 'rake/testtask'
73
+ require "minitest/test_task"
74
74
75
- Rake ::TestTask . new ( :test ) do |t |
76
- t . libs << 'lib'
77
- t . libs << 'test'
78
- t . pattern = ENV [ 'TEST_PATTERN' ] || 'test/**/*_test.rb'
79
- t . verbose = ENV [ 'TEST_VERBOSE' ] == '1'
75
+ Minitest ::TestTask . create ( :test ) do |t |
76
+ t . libs << "test"
77
+ t . libs << "lib"
80
78
t . warning = false
79
+ t . test_globs = ENV [ 'TEST_PATTERN' ] || 'test/**/*_test.rb'
80
+ t . verbose = ENV [ 'TEST_VERBOSE' ] == '1'
81
81
end
82
82
83
83
task default : :test
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ module.exports = function (api) {
2
2
const defaultConfigFunc = require ( 'shakapacker/package/babel/preset.js' )
3
3
const resultConfig = defaultConfigFunc ( api )
4
4
const isProductionEnv = api . env ( 'production' )
5
+ const isDevelopmentEnv = api . env ( 'development' )
5
6
6
7
const changesOnDefault = {
7
8
presets : [
@@ -15,6 +16,12 @@ module.exports = function (api) {
15
16
] . filter ( Boolean ) ,
16
17
plugins : [
17
18
process . env . WEBPACK_SERVE && 'react-refresh/babel' ,
19
+ ! isDevelopmentEnv && [
20
+ 'babel-plugin-transform-react-remove-prop-types' ,
21
+ {
22
+ removeImport : true ,
23
+ } ,
24
+ ] ,
18
25
] . filter ( Boolean ) ,
19
26
}
20
27
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+
3
+ require "pathname"
4
+ require "bundler/setup"
5
+ require "webpacker"
6
+ require "webpacker/webpack_runner"
7
+
8
+ ENV [ "RAILS_ENV" ] ||= "development"
9
+ ENV [ "NODE_ENV" ] ||= ENV [ "RAILS_ENV" ]
10
+ ENV [ "BUNDLE_GEMFILE" ] ||= File . expand_path ( "../../Gemfile" , Pathname . new ( __FILE__ ) . realpath )
11
+
12
+ APP_ROOT = File . expand_path ( ".." , __dir__ )
13
+ Dir . chdir ( APP_ROOT ) do
14
+ Webpacker ::WebpackRunner . run ( ARGV )
15
+ end
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV [ "RAILS_ENV" ] ||= "development"
4
+ ENV [ "NODE_ENV" ] ||= ENV [ "RAILS_ENV" ]
5
+
6
+ require "pathname"
7
+ ENV [ "BUNDLE_GEMFILE" ] ||= File . expand_path ( "../../Gemfile" ,
8
+ Pathname . new ( __FILE__ ) . realpath )
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/dev_server_runner"
14
+
15
+ APP_ROOT = File . expand_path ( ".." , __dir__ )
16
+ Dir . chdir ( APP_ROOT ) do
17
+ Webpacker ::DevServerRunner . run ( ARGV )
18
+ end
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const configureClient = () => {
7
7
// In case this entry is not deleted, a very strange "window" not found
8
8
// error shows referring to window["webpackJsonp"]. That is because the
9
9
// client config is going to try to load chunks.
10
- delete clientConfig . entry [ 'server-bundle ' ]
10
+ delete clientConfig . entry [ 'server_rendering ' ]
11
11
12
12
return clientConfig
13
13
}
Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ const configureServer = () => {
12
12
13
13
// We just want the single server bundle entry
14
14
const serverEntry = {
15
- 'server-bundle ' : serverWebpackConfig . entry [ 'server-bundle ' ]
15
+ 'server_rendering ' : serverWebpackConfig . entry [ 'server_rendering ' ]
16
16
}
17
17
18
- if ( ! serverEntry [ 'server-bundle ' ] ) {
19
- throw new Error ( 'Create a pack with the file name \'server-bundle .js\' containing all the server rendering files' )
18
+ if ( ! serverEntry [ 'server_rendering ' ] ) {
19
+ throw new Error ( 'Create a pack with the file name \'server_rendering .js\' containing all the server rendering files' )
20
20
}
21
21
22
22
serverWebpackConfig . entry = serverEntry
@@ -41,10 +41,10 @@ const configureServer = () => {
41
41
new webpack . optimize . LimitChunkCountPlugin ( { maxChunks : 1 } )
42
42
)
43
43
44
- // Custom output for the server-bundle that matches the config in
44
+ // Custom output for the server_rendering that matches the config in
45
45
// config/initializers/react_on_rails.rb
46
46
serverWebpackConfig . output = {
47
- filename : 'server-bundle .js' ,
47
+ filename : 'server_rendering .js' ,
48
48
globalObject : 'this' ,
49
49
// If using the React on Rails Pro node server renderer, uncomment the next line
50
50
// libraryTarget: 'commonjs2',
Original file line number Diff line number Diff line change
1
+ const { env, webpackConfig } = require ( 'shakapacker' ) ;
2
+ const { existsSync } = require ( 'fs' ) ;
3
+ const { resolve } = require ( 'path' ) ;
4
+
5
+ const envSpecificConfig = ( ) => {
6
+ const path = resolve ( __dirname , `${ env . nodeEnv } .js` ) ;
7
+ if ( existsSync ( path ) ) {
8
+ console . log ( `Loading ENV specific webpack configuration file ${ path } ` ) ;
9
+ return require ( path ) ;
10
+ } else {
11
+ return webpackConfig ;
12
+ }
13
+ } ;
14
+
15
+ module . exports = envSpecificConfig ( ) ;
Original file line number Diff line number Diff line change @@ -13,22 +13,6 @@ default: &default
13
13
# Reload manifest.json on all requests so we reload latest compiled packs
14
14
cache_manifest : false
15
15
16
- extensions :
17
- - .coffee
18
- - .erb
19
- - .js
20
- - .jsx
21
- - .ts
22
- - .vue
23
- - .sass
24
- - .scss
25
- - .css
26
- - .png
27
- - .svg
28
- - .gif
29
- - .jpeg
30
- - .jpg
31
-
32
16
development :
33
17
<< : *default
34
18
compile : true
Original file line number Diff line number Diff line change 9
9
"babel-loader" : " ^8.2.5" ,
10
10
"babel-plugin-macros" : " ^3.1.0" ,
11
11
"compression-webpack-plugin" : " ^9.2.0" ,
12
+ "create-react-class" : " ^15.6.2" ,
12
13
"css-loader" : " ^5.2.7" ,
13
14
"css-minimizer-webpack-plugin" : " ^2.0.0" ,
14
15
"mini-css-extract-plugin" : " ^1.6.2" ,
15
16
"pnp-webpack-plugin" : " ^1.7.0" ,
16
17
"react" : " ^17.0.2" ,
17
18
"react-dom" : " ^17.0.2" ,
19
+ "react_ujs" : " file:.yalc/react_ujs" ,
18
20
"shakapacker" : " ^6.4.1" ,
19
21
"style-loader" : " ^3.3.1" ,
20
22
"terser-webpack-plugin" : " ^5.3.3" ,
25
27
"webpack-sources" : " ^3.2.3"
26
28
},
27
29
"devDependencies" : {
30
+ "babel-plugin-transform-react-remove-prop-types" : " ^0.4.24" ,
28
31
"@pmmmwh/react-refresh-webpack-plugin" : " ^0.5.7" ,
29
32
"react-refresh" : " ^0.13.0" ,
30
33
"webpack-dev-server" : " ^4.9.2"
34
+ },
35
+ "scripts" : {
36
+ "yalc-postinstall" : " yalc link react_ujs"
31
37
}
32
38
}
You can’t perform that action at this time.
0 commit comments