react_on_rails 2.0.0.beta.1 → 2.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.dockerignore +2 -0
  4. data/.eslintignore +7 -0
  5. data/.eslintrc +19 -0
  6. data/.gitignore +28 -0
  7. data/.jscsrc +27 -0
  8. data/.npmignore +20 -0
  9. data/.rspec +2 -0
  10. data/.rubocop.yml +70 -0
  11. data/.scss-lint.yml +205 -0
  12. data/.travis.yml +43 -0
  13. data/CHANGELOG.md +34 -0
  14. data/Dockerfile_tests +12 -0
  15. data/Gemfile +40 -0
  16. data/README.md +365 -0
  17. data/Rakefile +5 -0
  18. data/app/helpers/react_on_rails_helper.rb +215 -0
  19. data/docker-compose.yml +11 -0
  20. data/docs/LICENSE +21 -0
  21. data/docs/additional_reading/heroku_deployment.md +23 -0
  22. data/docs/additional_reading/manual_installation.md +118 -0
  23. data/docs/additional_reading/node_dependencies_and_npm.md +29 -0
  24. data/docs/additional_reading/optional_configuration.md +33 -0
  25. data/docs/additional_reading/react-and-redux.md +36 -0
  26. data/docs/additional_reading/react_router.md +45 -0
  27. data/docs/additional_reading/server_rendering_tips.md +11 -0
  28. data/docs/additional_reading/tips.md +10 -0
  29. data/docs/additional_reading/webpack.md +46 -0
  30. data/docs/code_of_conduct.md +13 -0
  31. data/docs/coding-style/linters.md +64 -0
  32. data/docs/coding-style/style.md +42 -0
  33. data/docs/contributing.md +157 -0
  34. data/docs/generator_testing.md +20 -0
  35. data/docs/releasing.md +29 -0
  36. data/lib/generators/USAGE +99 -0
  37. data/lib/generators/react_on_rails/base_generator.rb +191 -0
  38. data/lib/generators/react_on_rails/bootstrap_generator.rb +89 -0
  39. data/lib/generators/react_on_rails/dev_tests_generator.rb +39 -0
  40. data/lib/generators/react_on_rails/generator_helper.rb +50 -0
  41. data/lib/generators/react_on_rails/heroku_deployment_generator.rb +30 -0
  42. data/lib/generators/react_on_rails/install_generator.rb +99 -0
  43. data/lib/generators/react_on_rails/js_linters_generator.rb +19 -0
  44. data/lib/generators/react_on_rails/react_no_redux_generator.rb +40 -0
  45. data/lib/generators/react_on_rails/react_with_redux_generator.rb +51 -0
  46. data/lib/generators/react_on_rails/ruby_linters_generator.rb +33 -0
  47. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +4 -0
  48. data/lib/generators/react_on_rails/templates/base/base/REACT_ON_RAILS.md +16 -0
  49. data/lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb +5 -0
  50. data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +4 -0
  51. data/lib/generators/react_on_rails/templates/base/base/client/.babelrc +3 -0
  52. data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md +3 -0
  53. data/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/clientRegistration.jsx.tt +5 -0
  54. data/lib/generators/react_on_rails/templates/base/base/client/index.jade +15 -0
  55. data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +104 -0
  56. data/lib/generators/react_on_rails/templates/base/base/client/server.js +64 -0
  57. data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js.tt +62 -0
  58. data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.hot.config.js.tt +69 -0
  59. data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +42 -0
  60. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +26 -0
  61. data/lib/generators/react_on_rails/templates/base/base/lib/tasks/assets.rake.tt +26 -0
  62. data/lib/generators/react_on_rails/templates/base/base/lib/tasks/linters.rake.tt +88 -0
  63. data/lib/generators/react_on_rails/templates/base/base/package.json +31 -0
  64. data/lib/generators/react_on_rails/templates/base/server_rendering/client/app/bundles/HelloWorld/startup/serverRegistration.jsx +4 -0
  65. data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +39 -0
  66. data/lib/generators/react_on_rails/templates/bootstrap/app/assets/stylesheets/_bootstrap-custom.scss +63 -0
  67. data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_post-bootstrap.scss +10 -0
  68. data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_pre-bootstrap.scss +8 -0
  69. data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_react-on-rails-sass-helper.scss +19 -0
  70. data/lib/generators/react_on_rails/templates/bootstrap/client/bootstrap-sass.config.js +89 -0
  71. data/lib/generators/react_on_rails/templates/dev_tests/.rspec +2 -0
  72. data/lib/generators/react_on_rails/templates/dev_tests/spec/features/hello_world_spec.rb +25 -0
  73. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +57 -0
  74. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +21 -0
  75. data/lib/generators/react_on_rails/templates/dev_tests/spec/spec_helper.rb +95 -0
  76. data/lib/generators/react_on_rails/templates/heroku_deployment/.buildpacks +2 -0
  77. data/lib/generators/react_on_rails/templates/heroku_deployment/Procfile +1 -0
  78. data/lib/generators/react_on_rails/templates/heroku_deployment/config/puma.rb +15 -0
  79. data/lib/generators/react_on_rails/templates/js_linters/client/.eslintignore +1 -0
  80. data/lib/generators/react_on_rails/templates/js_linters/client/.eslintrc +48 -0
  81. data/lib/generators/react_on_rails/templates/js_linters/client/.jscsrc +18 -0
  82. data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +39 -0
  83. data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +33 -0
  84. data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx.tt +8 -0
  85. data/lib/generators/react_on_rails/templates/no_redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +8 -0
  86. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx +8 -0
  87. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +48 -0
  88. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx +8 -0
  89. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +43 -0
  90. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx +19 -0
  91. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/index.jsx +14 -0
  92. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx.tt +19 -0
  93. data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/store/helloWorldStore.jsx +35 -0
  94. data/lib/generators/react_on_rails/templates/redux/base/client/app/lib/middlewares/loggerMiddleware.js +20 -0
  95. data/lib/generators/react_on_rails/templates/redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +19 -0
  96. data/lib/generators/react_on_rails/templates/ruby_linters/.rubocop.yml +26 -0
  97. data/lib/generators/react_on_rails/templates/ruby_linters/.scss-lint.yml +205 -0
  98. data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/brakeman.rake +17 -0
  99. data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/ci.rake +33 -0
  100. data/lib/generators/react_on_rails/templates/ruby_linters/ruby-lint.yml +20 -0
  101. data/lib/react_on_rails.rb +6 -0
  102. data/lib/react_on_rails/configuration.rb +60 -0
  103. data/lib/react_on_rails/engine.rb +7 -0
  104. data/lib/react_on_rails/prerender_error.rb +31 -0
  105. data/lib/react_on_rails/server_rendering_pool.rb +110 -0
  106. data/lib/react_on_rails/version.rb +3 -0
  107. data/package.json +76 -0
  108. data/rakelib/docker.rake +33 -0
  109. data/rakelib/dummy_apps.rake +20 -0
  110. data/rakelib/example_type.rb +160 -0
  111. data/rakelib/examples.rake +103 -0
  112. data/rakelib/examples_config.yml +19 -0
  113. data/rakelib/lint.rake +37 -0
  114. data/rakelib/node_package.rake +11 -0
  115. data/rakelib/run_rspec.rake +65 -0
  116. data/rakelib/task_helpers.rb +44 -0
  117. data/react_on_rails.gemspec +31 -0
  118. data/ruby-lint.yml +24 -0
  119. metadata +119 -2
@@ -0,0 +1,64 @@
1
+ // This file is used by the webpack HMR dev server to load your component without using Rails
2
+ // It should simply match routes to basic HTML or jade files that render your component
3
+ /* eslint-disable no-console, func-names, no-var */
4
+ var webpack = require('webpack');
5
+ var WebpackDevServer = require('webpack-dev-server');
6
+ var jade = require('jade');
7
+ var config = require('./webpack.client.hot.config');
8
+
9
+ var server = new WebpackDevServer(webpack(config), {
10
+ publicPath: config.output.publicPath,
11
+ hot: true,
12
+ historyApiFallback: true,
13
+ stats: {
14
+ colors: true,
15
+ hash: false,
16
+ version: false,
17
+ chunks: false,
18
+ children: false,
19
+ },
20
+ });
21
+
22
+ // The following code is commented out because the HelloWorld example
23
+ // does not use any asynchronous functionality. It is meant to serve
24
+ // as an example of how one might implement an API in express for their
25
+ // webpack dev server
26
+ // Note, it would be necessary to run `npm i --save body-parser sleep` for
27
+ // the following to work:
28
+ // var bodyParser = require('body-parser');
29
+ // var sleep = require('sleep');
30
+ // See tutorial for example of using AJAX:
31
+ // https://github.com/shakacode/react-webpack-rails-tutorial
32
+
33
+ // server.app.use(bodyParser.json(null));
34
+ // server.app.use(bodyParser.urlencoded({extended: true}));
35
+ // server.app.get('/hello_world.json', function(req, res) {
36
+ // res.setHeader('Content-Type', 'application/json');
37
+ // res.send(JSON.stringify(name));
38
+ // });
39
+
40
+ // server.app.post('/hello_world.json', function(req, res) {
41
+ // console.log('Processing name: %j', req.body.name);
42
+ // console.log('(shhhh...napping 1 seconds)');
43
+ // sleep.sleep(1);
44
+ // console.log('Just got done with nap!');
45
+ // name = req.body.name;
46
+ // res.setHeader('Content-Type', 'application/json');
47
+ // res.send(JSON.stringify(req.body.name));
48
+ // });
49
+
50
+ var initialName = 'Stranger';
51
+
52
+ server.app.use('/', function(req, res) {
53
+ var locals = {
54
+ props: JSON.stringify(initialName),
55
+ };
56
+ var layout = process.cwd() + '/index.jade';
57
+ var html = jade.compileFile(layout, { pretty: true })(locals);
58
+ res.send(html);
59
+ });
60
+
61
+ server.listen(4000, 'localhost', function(err) {
62
+ if (err) console.log(err);
63
+ console.log('Listening at localhost:4000...');
64
+ });
@@ -0,0 +1,62 @@
1
+ // Common client-side webpack configuration used by webpack.hot.config and webpack.rails.config.
2
+
3
+ const webpack = require('webpack');
4
+ const path = require('path');
5
+
6
+ const devBuild = process.env.NODE_ENV !== 'production';
7
+ const nodeEnv = devBuild ? 'development' : 'production';
8
+
9
+ module.exports = {
10
+
11
+ // the project dir
12
+ context: __dirname,
13
+ entry: {
14
+
15
+ // See use of 'vendor' in the CommonsChunkPlugin inclusion below.
16
+ vendor: [
17
+ 'babel-polyfill',
18
+ 'jquery',
19
+ ],
20
+
21
+ // This will contain the app entry points defined by webpack.hot.config and webpack.rails.config
22
+ app: [
23
+ './app/bundles/HelloWorld/startup/clientRegistration',
24
+ ],
25
+ },
26
+ resolve: {
27
+ extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', '.scss', '.css', 'config.js'],
28
+ alias: {
29
+ lib: path.join(process.cwd(), 'app', 'lib'),
30
+ },
31
+ },
32
+ plugins: [
33
+
34
+ new webpack.DefinePlugin({
35
+ 'process.env': {
36
+ NODE_ENV: JSON.stringify(nodeEnv),
37
+ },
38
+ }),
39
+
40
+ // https://webpack.github.io/docs/list-of-plugins.html#2-explicit-vendor-chunk
41
+ new webpack.optimize.CommonsChunkPlugin({
42
+
43
+ // This name 'vendor' ties into the entry definition
44
+ name: 'vendor',
45
+
46
+ // We don't want the default vendor.js name
47
+ filename: 'vendor-bundle.js',
48
+
49
+ // Passing Infinity just creates the commons chunk, but moves no modules into it.
50
+ // In other words, we only put what's in the vendor entry definition in vendor-bundle.js
51
+ minChunks: Infinity,
52
+ }),
53
+ ],
54
+ module: {
55
+ loaders: [
56
+
57
+ // Not all apps require jQuery. Many Rails apps do, such as those using TurboLinks or bootstrap js
58
+ {test: require.resolve('jquery'), loader: 'expose?jQuery'},
59
+ {test: require.resolve('jquery'), loader: 'expose?$'},
60
+ ],
61
+ },
62
+ };
@@ -0,0 +1,69 @@
1
+ // This config file setups up the Webpack Dev Server: https://webpack.github.io/docs/webpack-dev-server.html
2
+ // Run like this:
3
+ // cd client && node server.js
4
+
5
+ const webpack = require('webpack');
6
+ const path = require('path');
7
+ const config = require('./webpack.client.base.config');
8
+
9
+ config.entry.app.push(
10
+
11
+ // Webpack dev server
12
+ 'webpack-dev-server/client?http://localhost:4000',
13
+ 'webpack/hot/dev-server'<%- unless options.skip_bootstrap? -%>,
14
+
15
+ // See: https://github.com/shakacode/bootstrap-sass-loader
16
+ // We're using the bootstrap-sass loader.
17
+ 'bootstrap-sass!./bootstrap-sass.config.js'
18
+ <%- end -%>
19
+
20
+ );
21
+
22
+ config.output = {
23
+
24
+ // this file is served directly by webpack
25
+ filename: '[name]-bundle.js',
26
+ path: __dirname,
27
+ };
28
+ config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
29
+ config.devtool = 'eval-source-map';
30
+
31
+ // All the styling loaders only apply to hot-reload, not rails
32
+ config.module.loaders.push(
33
+ {
34
+ test: /\.jsx?$/,
35
+ loader: 'babel',
36
+ exclude: /node_modules/,
37
+ query: {
38
+ plugins: [
39
+ [
40
+ 'react-transform',
41
+ {
42
+ transforms: [
43
+ {
44
+ transform: 'react-transform-hmr',
45
+ imports: ['react'],
46
+ locals: ['module'],
47
+ },
48
+ ],
49
+ },
50
+ ],
51
+ ],
52
+ },
53
+ },
54
+ {test: /\.css$/, loader: 'style-loader!css-loader'},
55
+ {
56
+ test: /\.scss$/,
57
+ loader: 'style!css!sass?outputStyle=expanded&imagePath=/assets/images&includePaths[]=' +
58
+ path.resolve(__dirname, './assets/stylesheets'),
59
+ },
60
+
61
+ // The url-loader uses DataUrls. The file-loader emits files.
62
+ {test: /\.woff$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff'},
63
+ {test: /\.woff2$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff'},
64
+ {test: /\.ttf$/, loader: 'file-loader'},
65
+ {test: /\.eot$/, loader: 'file-loader'},
66
+ {test: /\.svg$/, loader: 'file-loader'}
67
+ );
68
+
69
+ module.exports = config;
@@ -0,0 +1,42 @@
1
+ // Run like this:
2
+ // cd client && npm run build:dev
3
+ // Note that Foreman (Procfile.dev) has also been configured to take care of this.
4
+
5
+ // NOTE: All style sheets handled by the asset pipeline in rails
6
+
7
+ const webpack = require('webpack');
8
+ const config = require('./webpack.client.base.config');
9
+ const devBuild = process.env.NODE_ENV !== 'production';
10
+
11
+ config.output = {
12
+ filename: '[name]-bundle.js',
13
+ path: '../app/assets/javascripts/generated',
14
+ };
15
+
16
+ // You can add entry points specific to rails here
17
+ // The es5-shim/sham is for capybara testing
18
+ config.entry.vendor.unshift(
19
+ 'es5-shim/es5-shim',
20
+ 'es5-shim/es5-sham'
21
+ );
22
+
23
+ config.entry.vendor.push('jquery-ujs');
24
+
25
+ // See webpack.common.config for adding modules common to both the webpack dev server and rails
26
+
27
+ config.module.loaders.push(
28
+ {test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/},
29
+ {test: require.resolve('react'), loader: 'imports?shim=es5-shim/es5-shim&sham=es5-shim/es5-sham'}
30
+ );
31
+
32
+ module.exports = config;
33
+
34
+ if (devBuild) {
35
+ console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
36
+ module.exports.devtool = 'eval-source-map';
37
+ } else {
38
+ config.plugins.push(
39
+ new webpack.optimize.DedupePlugin()
40
+ );
41
+ console.log('Webpack production build for Rails'); // eslint-disable-line no-console
42
+ }
@@ -0,0 +1,26 @@
1
+ # Shown below are the defaults for configuration
2
+ ReactOnRails.configure do |config|
3
+ # Client bundles are configured in application.js
4
+
5
+ # Server rendering:
6
+ # Server bundle is a single file for all server rendering of components.
7
+ config.server_bundle_js_file = "app/assets/javascripts/generated/server-bundle.js"
8
+ # increase if you're on JRuby
9
+ config.server_renderer_pool_size = 1
10
+ # seconds
11
+ config.server_renderer_timeout = 20
12
+ # If set to true, this forces Rails to reload the server bundle if it is modified
13
+ config.development_mode = Rails.env.development?
14
+ # For server rendering. This can be set to false so that server side messages are discarded.
15
+ # Default is true. Be cautious about turning this off.
16
+ config.replay_console = true
17
+ # Default is true. Logs server rendering messags to Rails.logger.info
18
+ config.logging_on_server = true
19
+
20
+ # The following options can be overriden by passing to the helper method:
21
+
22
+ # Default is false
23
+ config.prerender = false
24
+ # Default is true for development, off otherwise
25
+ config.trace = Rails.env.development?
26
+ end
@@ -0,0 +1,26 @@
1
+ # lib/tasks/assets.rake
2
+ # The webpack task must run before assets:environment task.
3
+ # Otherwise Sprockets cannot find the files that webpack produces.
4
+ # This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
5
+ Rake::Task["assets:precompile"]
6
+ .clear_prerequisites
7
+ .enhance(["assets:compile_environment"])
8
+
9
+ namespace :assets do
10
+ # In this task, set prerequisites for the assets:precompile task
11
+ task compile_environment: :webpack do
12
+ Rake::Task["assets:environment"].invoke
13
+ end
14
+
15
+ desc "Compile assets with webpack"
16
+ task :webpack do
17
+ sh "cd client && npm run build:client"
18
+ <%- if options[:server_rendering] -%>
19
+ sh "cd client && npm run build:server"
20
+ <%- end -%>
21
+ end
22
+
23
+ task :clobber do
24
+ rm_r Dir.glob(Rails.root.join("app/assets/javascripts/generated/*"))
25
+ end
26
+ end
@@ -0,0 +1,88 @@
1
+ if %w(development test).include? Rails.env
2
+ namespace :lint do
3
+ <%- if options.ruby_linters? -%>
4
+ # This fails: https://github.com/bbatsov/rubocop/issues/1840
5
+ # RuboCop::RakeTask.new
6
+ # require "rubocop/rake_task"
7
+ desc "Run Rubocop lint in shell. Specify option fix to auto-correct (and don't have uncommitted files!)."
8
+ task :rubocop, [:fix] => [] do |_t, args|
9
+ def to_bool(str)
10
+ return true if str =~ (/^(true|t|yes|y|1)$/i)
11
+ return false if str.blank? || str =~ (/^(false|f|no|n|0)$/i)
12
+ fail ArgumentError, "invalid value for Boolean: \"#{str}\""
13
+ end
14
+
15
+ fix = (args.fix == "fix") || to_bool(args.fix)
16
+ cmd = "rubocop -S -D#{fix ? ' -a' : ''} ."
17
+ puts "Running Rubocop Linters via `#{cmd}`#{fix ? ' auto-correct is turned on!' : ''}"
18
+ sh cmd
19
+ end
20
+
21
+ desc "Run ruby-lint as shell"
22
+ task :ruby do
23
+ cmd = "ruby-lint app config spec lib"
24
+ puts "Running ruby-lint Linters via `#{cmd}`"
25
+ sh cmd
26
+ end
27
+
28
+ desc "See docs for task 'scss_lint'"
29
+ task :scss do
30
+ begin
31
+ require 'scss_lint/rake_task'
32
+ SCSSLint::RakeTask.new do |t|
33
+ t.files = ["app/assets/stylesheets/", "client/assets/stylesheets/"]
34
+ end
35
+ Rake::Task[:scss_lint].invoke
36
+ rescue LoadError
37
+ puts "** add gem 'scss_lint' to your Gemfile for scss linting."
38
+ end
39
+ end
40
+
41
+ # desc "haml_lint"
42
+ # task :haml_lint do
43
+ # require 'haml_lint/rake_task'
44
+
45
+ # HamlLint::RakeTask.new do |t|
46
+ # t.files = ["app/views"]
47
+ # end
48
+ # end
49
+
50
+ # desc "See docs for task 'slim_lint'"
51
+ # task slim: :slim_lint
52
+ # SlimLint::RakeTask.new do |t|
53
+ # t.files = ["app/views"]
54
+ # end
55
+
56
+ <%- end -%>
57
+ <%- unless options.skip_js_linters? -%>
58
+ desc "eslint"
59
+ task :eslint do
60
+ cmd = "cd client && npm run eslint . -- --ext .jsx,.js"
61
+ puts "Running eslint via `#{cmd}`"
62
+ sh cmd
63
+ end
64
+
65
+ desc "jscs"
66
+ task :jscs do
67
+ cmd = "cd client && npm run jscs ."
68
+ puts "Running jscs via `#{cmd}`"
69
+ sh cmd
70
+ end
71
+
72
+ desc "JS Linting"
73
+ task js: [:eslint, :jscs] do
74
+ puts "Completed running all JavaScript Linters"
75
+ end
76
+ <%- end -%>
77
+
78
+ <%- enabled_linters = [] -%>
79
+ <%- enabled_linters << %i(rubocop ruby scss) if options.ruby_linters? -%>
80
+ <%- enabled_linters << %i(js) unless options.skip_js_linters? -%>
81
+ task lint: <%= enabled_linters.flatten %> do
82
+ puts "Completed all linting"
83
+ end
84
+ end
85
+
86
+ desc "Runs all linters. Run `rake -D lint` to see all available lint options"
87
+ task lint: ["lint:lint"]
88
+ end
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "react-webpack-rails-tutorial",
3
+ "version": "1.1.1",
4
+ "description": "Built using the react_on_rails generator. Allows you to run npm install from root.",
5
+ "main": "server.js",
6
+ "engines": {
7
+ "node": "4.2.0",
8
+ "npm": "3.3.6"
9
+ },
10
+ "scripts": {
11
+ "postinstall": "cd client && npm install",
12
+ "test": "rspec && (cd client && npm run lint)"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/shakacode/react-webpack-rails-tutorial.git"
17
+ },
18
+ "keywords": [
19
+ "react",
20
+ "tutorial",
21
+ "comment",
22
+ "example"
23
+ ],
24
+ "author": "justin808",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/shakacode/react-webpack-rails-tutorial/issues"
28
+ },
29
+ "homepage": "https://github.com/shakacode/react-webpack-rails-tutorial",
30
+ "dependencies": {}
31
+ }
@@ -0,0 +1,4 @@
1
+ import ReactOnRails from 'react-on-rails';
2
+ import HelloWorldApp from './HelloWorldAppServer';
3
+
4
+ ReactOnRails.register({ HelloWorldApp });
@@ -0,0 +1,39 @@
1
+ // Webpack configuration for server bundle
2
+
3
+ const webpack = require('webpack');
4
+ const path = require('path');
5
+
6
+ const devBuild = process.env.NODE_ENV !== 'production';
7
+ const nodeEnv = devBuild ? 'development' : 'production';
8
+
9
+ module.exports = {
10
+
11
+ // the project dir
12
+ context: __dirname,
13
+ entry: [
14
+ 'babel-polyfill',
15
+ './app/bundles/HelloWorld/startup/serverRegistration'
16
+ ],
17
+ output: {
18
+ filename: 'server-bundle.js',
19
+ path: '../app/assets/javascripts/generated',
20
+ },
21
+ resolve: {
22
+ extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', 'config.js'],
23
+ alias: {
24
+ lib: path.join(process.cwd(), 'app', 'lib'),
25
+ },
26
+ },
27
+ plugins: [
28
+ new webpack.DefinePlugin({
29
+ 'process.env': {
30
+ NODE_ENV: JSON.stringify('production'),
31
+ },
32
+ }),
33
+ ],
34
+ module: {
35
+ loaders: [
36
+ {test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/},
37
+ ],
38
+ },
39
+ };