diff options
| author | 0Napster | 2017-10-11 12:03:04 +0200 |
|---|---|---|
| committer | GitHub | 2017-10-11 12:03:04 +0200 |
| commit | bf6d0e38ac7dfd7f99d67169e665384edd047ec0 (patch) | |
| tree | e08a253483cc17a4ef5623e72e9df084f2217a5e /config | |
| parent | 98861e13d56403e75aa000d62880dcbc34987a37 (diff) | |
| parent | 8993eced364551163879dc1735ad7d583fc664ac (diff) | |
| download | chouette-core-bf6d0e38ac7dfd7f99d67169e665384edd047ec0.tar.bz2 | |
Merge pull request #86 from af83/webpacker
Add webpacker gem and migrate the React apps
Diffstat (limited to 'config')
| -rw-r--r-- | config/application.rb | 8 | ||||
| -rw-r--r-- | config/environments/production.rb | 2 | ||||
| -rw-r--r-- | config/webpack/development.js | 3 | ||||
| -rw-r--r-- | config/webpack/environment.js | 36 | ||||
| -rw-r--r-- | config/webpack/production.js | 12 | ||||
| -rw-r--r-- | config/webpack/test.js | 3 | ||||
| -rw-r--r-- | config/webpacker.yml | 63 |
7 files changed, 122 insertions, 5 deletions
diff --git a/config/application.rb b/config/application.rb index 05a9752b6..169c13e10 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,7 +28,7 @@ module ChouetteIhm config.i18n.default_locale = ENV.fetch('RAILS_LOCALE', 'fr').to_sym # Configure Browserify to use babelify to compile ES6 - config.browserify_rails.commandline_options = "-t [ babelify --presets [ react es2015 ] ]" + # config.browserify_rails.commandline_options = "-t [ babelify --presets [ react es2015 ] ]" config.active_record.observers = [:route_observer, :calendar_observer] config.active_record.raise_in_transactional_callbacks = true @@ -40,9 +40,9 @@ module ChouetteIhm Rails.application.config.assets.precompile += %w(spec_helper.js) # Make sure Browserify is triggered when # asked to serve javascript spec files - config.browserify_rails.paths << lambda { |p| - p.start_with?(Rails.root.join("spec/javascripts").to_s) - } + # config.browserify_rails.paths << lambda { |p| + # p.start_with?(Rails.root.join("spec/javascripts").to_s) + # } end end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 794c8bd88..8e21f0919 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -144,5 +144,5 @@ Rails.application.configure do config.rails_host = ENV.fetch('RAILS_HOST') # Set node env for browserify-rails - config.browserify_rails.node_env = "production" + # config.browserify_rails.node_env = "production" end diff --git a/config/webpack/development.js b/config/webpack/development.js new file mode 100644 index 000000000..b66885a3c --- /dev/null +++ b/config/webpack/development.js @@ -0,0 +1,3 @@ +const environment = require('./environment') + +module.exports = environment.toWebpackConfig()
\ No newline at end of file diff --git a/config/webpack/environment.js b/config/webpack/environment.js new file mode 100644 index 000000000..ae1deb610 --- /dev/null +++ b/config/webpack/environment.js @@ -0,0 +1,36 @@ +const { environment } = require('@rails/webpacker') +const webpack = require('webpack') +const UglifyJsPlugin = require('uglify-js') +const CleanWebpackPlugin = require('clean-webpack-plugin') + +let pathsToClean = [ + 'public/packs' +]; + +// the clean options to use +let cleanOptions = { + root: __dirname + '/../../', + verbose: true, + dry: false +}; + + +environment.plugins.set( + 'CleanWebpack', + new CleanWebpackPlugin(pathsToClean, cleanOptions) +) + +// environment.plugins.set('Provide', new webpack.ProvidePlugin({ +// $: 'jquery', +// jQuery: 'jquery', +// jquery: 'jquery' +// }) +// ) + +// const config = environment.toWebpackConfig() + +// config.resolve.alias = { +// jquery: "jquery/src/jquery", +// } + +module.exports = environment
\ No newline at end of file diff --git a/config/webpack/production.js b/config/webpack/production.js new file mode 100644 index 000000000..97b6a77ff --- /dev/null +++ b/config/webpack/production.js @@ -0,0 +1,12 @@ +const environment = require('./environment') + +environment.plugins.set( + 'UglifyJs', + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + } + }) +) + +module.exports = environment.toWebpackConfig()
\ No newline at end of file diff --git a/config/webpack/test.js b/config/webpack/test.js new file mode 100644 index 000000000..81269f651 --- /dev/null +++ b/config/webpack/test.js @@ -0,0 +1,3 @@ +const environment = require('./environment') + +module.exports = environment.toWebpackConfig() diff --git a/config/webpacker.yml b/config/webpacker.yml new file mode 100644 index 000000000..51afa9df5 --- /dev/null +++ b/config/webpacker.yml @@ -0,0 +1,63 @@ +# Note: You must restart bin/webpack-dev-server for changes to take effect + +default: &default + source_path: app/javascript + source_entry_path: packs + public_output_path: packs + cache_path: tmp/cache/webpacker + + # Additional paths webpack should lookup modules + # ['app/assets', 'engine/foo/app/assets'] + resolved_paths: [] + + # Reload manifest.json on all requests so we reload latest compiled packs + cache_manifest: false + + extensions: + - .coffee + - .erb + - .js + - .jsx + - .ts + - .vue + - .sass + - .scss + - .css + - .png + - .svg + - .gif + - .jpeg + - .jpg + +development: + <<: *default + compile: true + + # Reference: https://webpack.js.org/configuration/dev-server/ + dev_server: + https: false + host: localhost + port: 3035 + public: localhost:3035 + hmr: false + # Inline should be set to true if using HMR + inline: true + overlay: true + disable_host_check: true + use_local_ip: false + +test: + <<: *default + compile: true + + # Compile test packs to a separate directory + public_output_path: packs-test + +production: + <<: *default + + # Production depends on precompilation of packs prior to booting for performance. + compile: false + + # Cache manifest.json for performance + cache_manifest: true |
