opal-webpack-loader 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6c50ef73a0bbe4d3c9d4ed8cb9078866e5d3bc9472f0bb30c088aa34fa13d95
4
- data.tar.gz: ecb28e8ef777e9e6615e1dc96efa86873ef822cd440c9d1721a13ca167cbfdb3
3
+ metadata.gz: 36ee4b4cf00990f01430447febbf5e4653baa4943ba2a51291c99f823f693da2
4
+ data.tar.gz: f49ae31c397e48d3ce57db5a8ecca450122a535c98a7f02f984cfde26d3a243b
5
5
  SHA512:
6
- metadata.gz: 1e87b208b7d296bc16d0f67a15a15a065d006c31f3e526fea78c2a19b3515eeb99ae246e1a9753b3016ce88bfd3637d1ba4305b970ecf54d803a33a79fed6633
7
- data.tar.gz: 503e8c96600c0e7fe31a92a6c8d38f78db59b5ff2a5a5893161ea8942f226b91cc648be872eaa9f1db176162ef25f2094df437afd6f84bab13cac8b8d416a564
6
+ metadata.gz: 42eab87b24e890cd9968d7ecbb0d972f165acdc8a48ea8a6924935f3e4849cf9349b66553165e7dc63c7d7bad9603e7203ed0c7dd81554259a48a773605ce12e
7
+ data.tar.gz: dbf524e9ec8777290df3eb436ff9f890073eb83c458b03a70ad308644a7ec78236a4710d749fea9166706e55d6371e72b00988c10b45b2f340cb24a284a5f5b5
@@ -183,6 +183,7 @@ module OpalWebpackLoader
183
183
  package_json["scripts"]["development"] = development_script
184
184
  package_json["scripts"]["production_build"] = production_script
185
185
  package_json["devDependencies"] = {} unless package_json.has_key?("devDependencies")
186
+ package_json["devDependencies"]["chokidar"] = gem_package_json["devDependencies"]["chokidar"]
186
187
  package_json["devDependencies"]["compression-webpack-plugin"] = gem_package_json["devDependencies"]["compression-webpack-plugin"]
187
188
  package_json["devDependencies"]["opal-webpack-loader"] = OpalWebpackLoader::VERSION
188
189
  package_json["devDependencies"]["webpack"] = gem_package_json["devDependencies"]["webpack"]
@@ -240,7 +241,28 @@ module OpalWebpackLoader
240
241
  js_ssr_entry: File.join(@conf_rel_prefix, @js_entrypoints_directory, 'application_ssr.js'),
241
242
  opal_directory: File.join(@conf_rel_prefix, @opal_directory),
242
243
  stylesheets_directory: File.join(@conf_rel_prefix, @styles_directory),
244
+ hmr_hook: ''
243
245
  }
246
+ if @js_entrypoints_directory.start_with?('app')
247
+ erb_hash[:dev_server_before] = <<~JAVASCRIPT
248
+ // enable page reload for updates within the app/views directory
249
+ before: function(app, server) {
250
+ chokidar.watch(path.resolve(__dirname, path.join('..', '..', 'app', 'views'))).on('all', function () {
251
+ server.sockWrite(server.sockets, 'content-changed');
252
+ })
253
+ },
254
+ JAVASCRIPT
255
+ else
256
+ erb_hash[:dev_server_before] = <<~JAVASCRIPT
257
+ // uncomment to enable page reload for updates within another directory, which may contain just html files,
258
+ // for example the 'views' directory:
259
+ // before: function(app, server) {
260
+ // chokidar.watch(path.resolve(__dirname, path.join('..', 'views')).on('all', function () {
261
+ // server.sockWrite(server.sockets, 'content-changed');
262
+ // })
263
+ // },
264
+ JAVASCRIPT
265
+ end
244
266
  create_file_from_template('debug.js.erb', File.join(@webpack_config_directory, 'debug.js'), erb_hash)
245
267
  create_file_from_template('development.js.erb', File.join(@webpack_config_directory, 'development.js'), erb_hash)
246
268
  create_file_from_template('production.js.erb', File.join(@webpack_config_directory, 'production.js'), erb_hash)
@@ -16,10 +16,5 @@ import init_app from '<%= opal_dir %>/<%= opal_name %>_loader.rb';
16
16
  init_app();
17
17
  Opal.load('<%= opal_name %>_loader');
18
18
 
19
-
20
19
  // allow for hot reloading
21
- if (module.hot) {
22
- module.hot.accept('./application.js', function() {
23
- console.log('Accepting the updated application.js!');
24
- })
25
- }
20
+ if (module.hot) { module.hot.accept(); }
@@ -5,4 +5,7 @@
5
5
  // example:
6
6
  //
7
7
  // import * as Redux from 'redux';
8
- // global.Redux = Redux;
8
+ // global.Redux = Redux;
9
+
10
+ // allow for hot reloading
11
+ if (module.hot) { module.hot.accept(); }
@@ -6,8 +6,4 @@ import './application.js';
6
6
  // space additional modules for debugging or helper code
7
7
 
8
8
  // allow for hot reloading
9
- if (module.hot) {
10
- module.hot.accept('./application_debug.js', function() {
11
- console.log('Accepting the updated application_debug.js!');
12
- })
13
- }
9
+ if (module.hot) { module.hot.accept(); }
@@ -16,8 +16,5 @@ import init_app from '<%= opal_dir %>/<%= opal_name %>_loader.rb';
16
16
  init_app();
17
17
  Opal.load('<%= opal_name %>_loader');
18
18
 
19
- if (module.hot) {
20
- module.hot.accept('./application_ssr.js', function() {
21
- console.log('Accepting the updated application_ssr.js!');
22
- })
23
- }
19
+ // allow for hot reloading
20
+ if (module.hot) { module.hot.accept(); }
@@ -1,6 +1,7 @@
1
1
  // require requirements used below
2
2
  const path = require('path');
3
3
  const webpack = require('webpack');
4
+ const chokidar = require('chokidar');
4
5
  const OwlResolver = require('opal-webpack-loader/resolver'); // to resolve ruby files
5
6
 
6
7
  module.exports = {
@@ -110,7 +111,9 @@ module.exports = {
110
111
  {
111
112
  loader: 'opal-webpack-loader',
112
113
  options: {
113
- sourceMap: true
114
+ sourceMap: true,
115
+ hmr: true,
116
+ hmrHook: '<%= hmr_hook %>'
114
117
  }
115
118
  }
116
119
  ]
@@ -119,6 +122,7 @@ module.exports = {
119
122
  },
120
123
  // configuration for webpack-dev-server
121
124
  devServer: {
125
+ <%= dev_server_before %>
122
126
  open: false,
123
127
  lazy: false,
124
128
  port: 3035,
@@ -1,6 +1,7 @@
1
1
  // require requirements used below
2
2
  const path = require('path');
3
3
  const webpack = require('webpack');
4
+ const chokidar = require('chokidar');
4
5
  const OwlResolver = require('opal-webpack-loader/resolver'); // to resolve ruby files
5
6
 
6
7
  module.exports = {
@@ -97,6 +98,11 @@ module.exports = {
97
98
  use: [
98
99
  {
99
100
  loader: 'opal-webpack-loader',
101
+ options: {
102
+ sourceMap: false,
103
+ hmr: true,
104
+ hmrHook: '<%= hmr_hook %>'
105
+ }
100
106
  }
101
107
  ]
102
108
  }
@@ -104,6 +110,7 @@ module.exports = {
104
110
  },
105
111
  // configuration for webpack-dev-server
106
112
  devServer: {
113
+ <%= dev_server_before %>
107
114
  open: false,
108
115
  lazy: false,
109
116
  port: 3035,
@@ -7,6 +7,7 @@
7
7
  "production_build": "<%= production_script %>"
8
8
  },
9
9
  "devDependencies": {
10
+ "chokidar": "^2.1.5",
10
11
  "compression-webpack-plugin": "^2.0.0",
11
12
  "opal-webpack-loader": "^<%= owl_version %>",
12
13
  "webpack": "^4.30.0",
@@ -96,7 +96,8 @@ module.exports = {
96
96
  {
97
97
  loader: 'opal-webpack-loader',
98
98
  options: {
99
- sourceMap: false
99
+ sourceMap: false,
100
+ hmr: false
100
101
  }
101
102
  }
102
103
  ]
@@ -1,3 +1,3 @@
1
1
  module OpalWebpackLoader
2
- VERSION="0.5.1"
2
+ VERSION="0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-webpack-loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-23 00:00:00.000000000 Z
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal