opal-webpack-loader 0.5.0 → 0.5.1

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: b195faad06e86f99145977d3551f71b22ff4717f9c3750572061a18e88b57c0e
4
- data.tar.gz: 943969a8513c3acf8d28da2039a88d418f443c136fab28e3ddf689883b6e9c95
3
+ metadata.gz: e6c50ef73a0bbe4d3c9d4ed8cb9078866e5d3bc9472f0bb30c088aa34fa13d95
4
+ data.tar.gz: ecb28e8ef777e9e6615e1dc96efa86873ef822cd440c9d1721a13ca167cbfdb3
5
5
  SHA512:
6
- metadata.gz: 565979248f76810bcb6783a18dac93276ea69bc6ca45bdeadf2b5c055a21e56f1829d83f3df4ec9ca29e5cea1355a4996efcf9c572fbd6d26429665499a5020f
7
- data.tar.gz: 68a3c55de9b28a6ca91a6e98a68e5920cd5ac314aab15e38db09954ea8d9cf311970c768640d9251b4d10fd2c44f63d76a89d09f9ac07ee98f5ee2fdb599770e
6
+ metadata.gz: 1e87b208b7d296bc16d0f67a15a15a065d006c31f3e526fea78c2a19b3515eeb99ae246e1a9753b3016ce88bfd3637d1ba4305b970ecf54d803a33a79fed6633
7
+ data.tar.gz: 503e8c96600c0e7fe31a92a6c8d38f78db59b5ff2a5a5893161ea8942f226b91cc648be872eaa9f1db176162ef25f2094df437afd6f84bab13cac8b8d416a564
data/bin/owl-install ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'erb'
3
+ # require 'active_support/core_ext/string'
4
+ require 'thor'
5
+ require 'oj'
6
+ require_relative '../lib/opal-webpack-loader/installer_cli'
7
+ require_relative '../lib/opal-webpack-loader/version'
8
+ OpalWebpackLoader::Installer::CLI.start(ARGV)
@@ -43,9 +43,9 @@ module OpalWebpackCompileServer
43
43
  result['source_map']['names'] = result['source_map']['names'].map(&:to_s)
44
44
  end
45
45
  result['required_trees'] = c.required_trees
46
- Oj.dump(result)
46
+ Oj.dump(result, {})
47
47
  rescue Exception => e
48
- Oj.dump({ 'error' => { 'name' => e.class, 'message' => e.message, 'backtrace' => e.backtrace } })
48
+ Oj.dump({ 'error' => { 'name' => e.class, 'message' => e.message, 'backtrace' => e.backtrace } }, {})
49
49
  end
50
50
  end
51
51
 
@@ -66,6 +66,7 @@ module OpalWebpackCompileServer
66
66
  dir_entries.each do |entry|
67
67
  next if entry == '.'
68
68
  next if entry == '..'
69
+ next unless entry
69
70
  absolute_path = File.join(path, entry)
70
71
  if File.directory?(absolute_path)
71
72
  more_path_entries = get_load_path_entries(absolute_path)
@@ -78,13 +79,13 @@ module OpalWebpackCompileServer
78
79
  end
79
80
 
80
81
  def self.get_load_paths
81
- load_paths = if File.exist?('bin/rails')
82
+ load_paths = if File.exist?(File.join('bin', 'rails'))
82
83
  %x{
83
84
  bundle exec rails runner "puts (Rails.configuration.respond_to?(:assets) ? (Rails.configuration.assets.paths + Opal.paths).uniq : Opal.paths)"
84
85
  }
85
86
  else
86
87
  %x{
87
- bundle exec ruby -e 'require "bundler/setup"; Bundler.require; set :run, false if defined? Sinatra; puts Opal.paths'
88
+ bundle exec ruby -e 'if File.exist?("app_loader.rb"); require "./app_loader.rb"; else; require "bundler/setup"; Bundler.require; set :run, false if defined? Sinatra; end; puts Opal.paths'
88
89
  }
89
90
  end
90
91
  if $? == 0
@@ -102,7 +103,7 @@ module OpalWebpackCompileServer
102
103
  end
103
104
  cache_obj = { 'opal_load_paths' => load_path_lines, 'opal_load_path_entries' => load_path_entries }
104
105
  Dir.mkdir(OpalWebpackCompileServer::OWL_CACHE_DIR) unless Dir.exist?(OpalWebpackCompileServer::OWL_CACHE_DIR)
105
- File.write(OpalWebpackCompileServer::OWL_LP_CACHE, Oj.dump(cache_obj))
106
+ File.write(OpalWebpackCompileServer::OWL_LP_CACHE, Oj.dump(cache_obj, {}))
106
107
  load_path_lines
107
108
  else
108
109
  raise 'Error getting load paths!'
@@ -0,0 +1,305 @@
1
+ module OpalWebpackLoader
2
+ module Installer
3
+ TARGETS = %w[development.js production.js test.js]
4
+ DEV_START_COMMAND = 'yarn run development'
5
+ DEV_SM_START_COMMAND = 'yarn run sourcemaps'
6
+
7
+ class CLI < Thor
8
+ desc "iso", "Install owl configuration into a existing isomorfeus project, meant to be called from the isomorfeus installer only."
9
+ # Showing directories and files relevant to iso owl:
10
+ # project_root
11
+ # +- config.ru # rack app starter
12
+ # +- config # webpack and other config
13
+ # +- owl.rb # owl.configuration
14
+ # +- isomorfeus
15
+ # +- components
16
+ # +- imports # javascript entrypoints, import other components etc.
17
+ # +- application.js
18
+ # +- application_common.js
19
+ # +- application_debug.js
20
+ # +- application_ssr.js
21
+ # +- isomorfeus_loader.rb
22
+ # +- models
23
+ # +- operations
24
+ # +- policies
25
+ # +- styles
26
+ # +- css
27
+ # +- log
28
+ # +- node_modules
29
+ # +- package.json
30
+ # +- Procfile
31
+ # +- public
32
+ # +- assets # compiled assets and other things
33
+ # +- spec
34
+ # +- tmp
35
+ def iso
36
+ @asset_output_directory = File.join('public', 'assets')
37
+ @js_entrypoints_directory = File.join('isomorfeus', 'imports')
38
+ @conf_rel_prefix = '..'
39
+ @js_rel_prefix = '..'
40
+ @opal_directory = 'isomorfeus'
41
+ @styles_directory = File.join(@opal_directory, 'styles')
42
+ @webpack_config_directory = 'webpack'
43
+ create_common_directories
44
+ create_isomorfeus_directories
45
+ install_webpack_config
46
+ create_file_from_template('initializer.rb.erb', File.join('config', 'owl_init.rb'), {})
47
+ add_gem
48
+ print_message
49
+ end
50
+
51
+ desc "flat", "Install owl configuration into a existing project with a flat structure, execute from the projects root directory."
52
+ # <<~TEXT
53
+ # Showing directories and files relevant to owl:
54
+ # project_root
55
+ # +- owl_init.rb # initializer for owl
56
+ # +- javascripts # javascript entries directory
57
+ # +- node_modules # directory for node modules
58
+ # +- opal # directory for opal application files, can be changed with -o
59
+ # +- package.json # package config for npm/yarn and their scripts
60
+ # +- public
61
+ # +- assets # directory for compiled output files
62
+ # +- styles # directory for stylesheets
63
+ # +- webpack # directory for webpack configuration files
64
+ # +- Procfile # config file for foreman
65
+ #
66
+ # TEXT
67
+ option :opal_name, required: false, type: :string, default: 'opal', aliases: '-o', desc: <<~TEXT
68
+ Set directory name for Opal source files.
69
+ Example: owl-installer rails -o isomorfeus # will use project_root/app/isomorfeus for opal files
70
+ TEXT
71
+
72
+ def flat
73
+ @asset_output_directory = File.join('public', 'assets')
74
+ @js_entrypoints_directory = File.join('javascripts')
75
+ @conf_rel_prefix = '..'
76
+ @js_rel_prefix = '..'
77
+ @opal_directory = options[:opal_name]
78
+ @styles_directory = 'styles'
79
+ @webpack_config_directory = 'webpack'
80
+ create_directory(@styles_directory)
81
+ create_common_directories
82
+ install_common_things
83
+ create_file_from_template('initializer.rb.erb', 'owl_init.rb', {})
84
+ add_gem
85
+ print_message
86
+ puts "Make sure to require the owl initializer, e.g. `require './owl_init'`, in your projects startup file."
87
+ end
88
+
89
+ desc "rails", "Install owl configuration into a existing rails project, execute from the projects root directory."
90
+ # <<~TEXT
91
+ # Showing directories and files relevant to owl:
92
+ # project_root
93
+ # +- app
94
+ # +- assets
95
+ # +- javascripts # javascript entries directory
96
+ # +- styles # directory for stylesheets
97
+ # +- opal # directory for opal application files, can be changed with -o
98
+ # +- config
99
+ # +- webpack # directory for webpack configuration files
100
+ # +- initializers
101
+ # +- owl.rb # initializer for owl
102
+ # +- node_modules # directory for node modules
103
+ # +- package.json # package config for npm/yarn and their scripts
104
+ # +- public
105
+ # +- assets # directory for compiled output files
106
+ # +- Procfile # config file for foreman
107
+ #
108
+ # TEXT
109
+ option :opal_name, required: false, type: :string, default: 'opal', aliases: '-o', desc: <<~TEXT
110
+ Set directory name for Opal source files.
111
+ Example: owl-installer rails -o isomorfeus # will use project_root/app/isomorfeus for opal files
112
+ TEXT
113
+
114
+ def rails
115
+ @asset_output_directory = File.join('public', 'assets')
116
+ @js_entrypoints_directory = File.join('app', 'assets', 'javascripts')
117
+ @conf_rel_prefix = File.join('..', '..')
118
+ @js_rel_prefix = File.join('..', '..', '..')
119
+ @opal_directory = File.join('app', options[:opal_name])
120
+ @styles_directory = File.join('app', 'assets', 'stylesheets')
121
+ @webpack_config_directory = File.join('config', 'webpack')
122
+ create_directory('app')
123
+ create_directory(@styles_directory)
124
+ create_common_directories
125
+ install_common_things
126
+ create_file_from_template('initializer.rb.erb', File.join('config', 'initializers', 'opal_webpack_loader.rb'), {})
127
+ add_gem
128
+ print_message
129
+ end
130
+
131
+ private
132
+
133
+ def create_directory(directory)
134
+ unless Dir.exist?(directory)
135
+ puts "Creating directory #{directory}."
136
+ FileUtils.mkdir_p(directory)
137
+ end
138
+ end
139
+
140
+ def create_common_directories
141
+ create_directory(@webpack_config_directory)
142
+ create_directory(@js_entrypoints_directory)
143
+ create_directory(@opal_directory)
144
+ create_directory(@asset_output_directory)
145
+ end
146
+
147
+ def create_isomorfeus_directories
148
+ create_directory(File.join('isomorfeus', 'components'))
149
+ create_directory(File.join('isomorfeus', 'models'))
150
+ create_directory(File.join('isomorfeus', 'operations'))
151
+ create_directory(File.join('isomorfeus', 'policies'))
152
+ create_directory(File.join('isomorfeus', 'styles'))
153
+ end
154
+
155
+ def install_common_things
156
+ install_webpack_config
157
+ install_package_json
158
+ install_js_entries
159
+ install_opal_entry
160
+ install_procfile
161
+ end
162
+
163
+ def install_js_entries
164
+ erb_hash = { opal_dir: File.join(@js_rel_prefix, @opal_directory), opal_name: options[:opal_name] }
165
+ create_file_from_template('application.js.erb', File.join(@js_entrypoints_directory, 'application.js'), erb_hash)
166
+ create_file_from_template('application_common.js.erb', File.join(@js_entrypoints_directory, 'application_common.js'),erb_hash)
167
+ create_file_from_template('application_debug.js.erb', File.join(@js_entrypoints_directory, 'application_debug.js'), erb_hash)
168
+ create_file_from_template('application_ssr.js.erb', File.join(@js_entrypoints_directory, 'application_ssr.js'), erb_hash)
169
+ end
170
+
171
+ def install_opal_entry
172
+ create_file_from_template('opal_loader.rb.erb', File.join(@opal_directory, "#{options[:opal_name]}_loader.rb"), {})
173
+ end
174
+
175
+ def install_package_json
176
+ if File.exist?('package.json')
177
+ gem_package_json_template = File.read(File.join(templates_path, 'package.json.erb'))
178
+ gem_package_json = Oj.load(gem_package_json_template, mode: :strict)
179
+ package_json_file = File.read('package.json')
180
+ package_json = Oj.load(package_json_file, mode: :strict)
181
+ package_json["scripts"] = {} unless package_json.has_key?("scripts")
182
+ package_json["scripts"]["debug"] = debug_script
183
+ package_json["scripts"]["development"] = development_script
184
+ package_json["scripts"]["production_build"] = production_script
185
+ package_json["devDependencies"] = {} unless package_json.has_key?("devDependencies")
186
+ package_json["devDependencies"]["compression-webpack-plugin"] = gem_package_json["devDependencies"]["compression-webpack-plugin"]
187
+ package_json["devDependencies"]["opal-webpack-loader"] = OpalWebpackLoader::VERSION
188
+ package_json["devDependencies"]["webpack"] = gem_package_json["devDependencies"]["webpack"]
189
+ package_json["devDependencies"]["webpack-cli"] = gem_package_json["devDependencies"]["webpack-cli"]
190
+ package_json["devDependencies"]["webpack-dev-server"] = gem_package_json["devDependencies"]["webpack-dev-server"]
191
+ package_json["devDependencies"]["webpack-manifest-plugin"] = gem_package_json["devDependencies"]["webpack-manifest-plugin"]
192
+ File.write('package.json', Oj.dump(package_json, mode: :strict))
193
+ puts "Updated package.json, updated scripts and owl dependencies"
194
+ else
195
+ erb_hash = {
196
+ debug_script: debug_script,
197
+ development_script: development_script,
198
+ production_script: production_script,
199
+ owl_version: OpalWebpackLoader::VERSION
200
+ }
201
+ create_file_from_template('package.json.erb', 'package.json', erb_hash)
202
+ end
203
+ end
204
+
205
+ def install_procfile
206
+ if File.exist?('Procfile')
207
+ procfile = File.read('Procfile')
208
+ has_webpack = false
209
+ lines = procfile.lines
210
+ lines.each do |line|
211
+ has_webpack = true if line.start_with?('webpack')
212
+ end
213
+ unless has_webpack
214
+ lines << 'webpack: yarn run development'
215
+ File.write('Procfile', lines.join("\n"))
216
+ end
217
+ else
218
+ create_file_from_template('Procfile.erb', 'Procfile',{})
219
+ end
220
+ end
221
+
222
+ def debug_script
223
+ "bundle exec opal-webpack-compile-server start webpack-dev-server --config #{File.join(@webpack_config_directory, 'debug.js')}"
224
+ end
225
+
226
+ def development_script
227
+ "bundle exec opal-webpack-compile-server start webpack-dev-server --config #{File.join(@webpack_config_directory, 'development.js')}"
228
+ end
229
+
230
+ def production_script
231
+ "bundle exec opal-webpack-compile-server start webpack --config=#{File.join(@webpack_config_directory, 'production.js')}"
232
+ end
233
+
234
+ def install_webpack_config
235
+ erb_hash = {
236
+ asset_output_directory: File.join(@conf_rel_prefix, @asset_output_directory),
237
+ js_entry: File.join(@conf_rel_prefix, @js_entrypoints_directory, 'application.js'),
238
+ js_common_entry: File.join(@conf_rel_prefix, @js_entrypoints_directory, 'application_common.js'),
239
+ js_debug_entry: File.join(@conf_rel_prefix, @js_entrypoints_directory, 'application_debug.js'),
240
+ js_ssr_entry: File.join(@conf_rel_prefix, @js_entrypoints_directory, 'application_ssr.js'),
241
+ opal_directory: File.join(@conf_rel_prefix, @opal_directory),
242
+ stylesheets_directory: File.join(@conf_rel_prefix, @styles_directory),
243
+ }
244
+ create_file_from_template('debug.js.erb', File.join(@webpack_config_directory, 'debug.js'), erb_hash)
245
+ create_file_from_template('development.js.erb', File.join(@webpack_config_directory, 'development.js'), erb_hash)
246
+ create_file_from_template('production.js.erb', File.join(@webpack_config_directory, 'production.js'), erb_hash)
247
+ end
248
+
249
+ def templates_path
250
+ File.realpath(File.join(File.dirname(File.realpath(__FILE__)), 'templates'))
251
+ end
252
+
253
+ def create_file_from_template(template_path, target_file_path, data_hash)
254
+ template = ERB.new(File.read(File.join(templates_path, template_path), mode: 'r'))
255
+ result = template.result_with_hash(data_hash)
256
+ if File.exist?(target_file_path)
257
+ ext = '_owl_new'
258
+ puts "#{target_file_path} exists, not overwriting, creating #{target_file_path + ext} instead."
259
+ else
260
+ ext = ''
261
+ puts "Creating #{target_file_path}."
262
+ end
263
+
264
+ File.write(target_file_path + ext, result, mode: 'w')
265
+ end
266
+
267
+ def add_gem
268
+ # TODO
269
+ # STDERR.puts File.read('Gemfile')
270
+ # STDERR.puts OpalWebpackLoader::VERSION
271
+ # `bundle add opal-webpack-loader -v "#{OpalWebpackLoader::VERSION}" --skip-install`
272
+ # specifying a version results in a bundler printing a error and not adding the gem
273
+ end
274
+
275
+ def print_message
276
+ puts <<~TEXT
277
+
278
+ Add the following lines to your Gemfile:
279
+
280
+ gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export'
281
+ gem 'opal-webpack-loader', '~> #{OpalWebpackLoader::VERSION}'
282
+
283
+ owl currently works only with above opal branch. If you have a existing "gem 'opal'", please replace it with above line.
284
+
285
+ Also check above output for files ending in '_owl_new' and merge their contents with the existing files.
286
+
287
+ After that run according to your preference either:
288
+
289
+ yarn install
290
+
291
+ or:
292
+
293
+ npm install
294
+
295
+ and then:
296
+
297
+ bundle install
298
+
299
+ For further instructions see http://github.com/isomorfeus/opal-webpack-loader
300
+
301
+ TEXT
302
+ end
303
+ end
304
+ end
305
+ end
@@ -9,5 +9,9 @@ module OpalWebpackLoader
9
9
  javascript_include_tag("#{OpalWebpackLoader.client_asset_path}#{path}")
10
10
  end
11
11
  end
12
+
13
+ def application_script_tag
14
+ javascript_include_tag("#{OpalWebpackLoader.application_js_path}")
15
+ end
12
16
  end
13
17
  end
@@ -0,0 +1 @@
1
+ webpack: yarn run development
@@ -0,0 +1,25 @@
1
+ // entry file for the browser environment
2
+ // import npm modules that are valid to use only in the browser
3
+ // for example modules which depend on the window or document objects of the browser
4
+ //
5
+ // example:
6
+ //
7
+ // import ReactDOM from 'react-dom';
8
+ // global.ReactDOM = ReactDOM;
9
+
10
+ // import modules common to browser and server side rendering (ssr)
11
+ // environments from application_common.js
12
+ import './application_common.js';
13
+
14
+ // import and load opal ruby files
15
+ import init_app from '<%= opal_dir %>/<%= opal_name %>_loader.rb';
16
+ init_app();
17
+ Opal.load('<%= opal_name %>_loader');
18
+
19
+
20
+ // 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
+ }
@@ -0,0 +1,8 @@
1
+ // import here all npm modules that are common to browser and server side rendering (ssr) environments
2
+ // modules should not depend on the window or document objects of the browser
3
+ // use global to make sure they are available globally
4
+ //
5
+ // example:
6
+ //
7
+ // import * as Redux from 'redux';
8
+ // global.Redux = Redux;
@@ -0,0 +1,13 @@
1
+ // entry file for the browser debugging environment
2
+
3
+ // import application.js
4
+ import './application.js';
5
+
6
+ // space additional modules for debugging or helper code
7
+
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
+ }
@@ -0,0 +1,23 @@
1
+ // entry file for the server side rendering environment (ssr)
2
+ // import npm modules that are only valid to use in the server side rendering environment
3
+ // for example modules which depend on objects provided by node js
4
+ //
5
+ // example:
6
+ //
7
+ // import ReactDOMServer from 'react-dom/server';
8
+ // global.ReactDOMServer = ReactDOMServer;
9
+
10
+ // import modules common to browser and server side rendering (ssr)
11
+ // environments from application_common.js
12
+ import './application_common.js';
13
+
14
+ // import and load opal ruby files
15
+ import init_app from '<%= opal_dir %>/<%= opal_name %>_loader.rb';
16
+ init_app();
17
+ Opal.load('<%= opal_name %>_loader');
18
+
19
+ if (module.hot) {
20
+ module.hot.accept('./application_ssr.js', function() {
21
+ console.log('Accepting the updated application_ssr.js!');
22
+ })
23
+ }
@@ -0,0 +1,145 @@
1
+ // require requirements used below
2
+ const path = require('path');
3
+ const webpack = require('webpack');
4
+ const OwlResolver = require('opal-webpack-loader/resolver'); // to resolve ruby files
5
+
6
+ module.exports = {
7
+ context: path.resolve(__dirname, '<%= opal_directory %>'),
8
+ mode: "development",
9
+ optimization: {
10
+ minimize: false // dont minimize for debugging
11
+ },
12
+ performance: {
13
+ maxAssetSize: 20000000,
14
+ maxEntrypointSize: 20000000
15
+ },
16
+ // use one of these below for source maps
17
+ devtool: 'source-map', // this works well, good compromise between accuracy and performance
18
+ // devtool: 'cheap-eval-source-map', // less accurate
19
+ // devtool: 'inline-source-map', // slowest
20
+ // devtool: 'inline-cheap-source-map',
21
+ entry: {
22
+ application: [path.resolve(__dirname, '<%= js_debug_entry %>')],
23
+ application_ssr: [path.resolve(__dirname, '<%= js_ssr_entry %>')]
24
+ },
25
+ output: {
26
+ // webpack-dev-server keeps the output in memory
27
+ filename: '[name].js',
28
+ path: path.resolve(__dirname, '<%= asset_output_directory %>'),
29
+ publicPath: 'http://localhost:3035/assets/'
30
+ },
31
+ resolve: {
32
+ plugins: [
33
+ // this makes it possible for webpack to find ruby files
34
+ new OwlResolver('resolve', 'resolved')
35
+ ],
36
+ alias: {
37
+ 'react-dom': 'react-dom/profiling',
38
+ 'schedule/tracing': 'schedule/tracing-profiling',
39
+ }
40
+ },
41
+ plugins: [
42
+ // both for hot reloading
43
+ new webpack.NamedModulesPlugin(),
44
+ new webpack.HotModuleReplacementPlugin()
45
+ ],
46
+ module: {
47
+ rules: [
48
+ {
49
+ // loader for .scss files
50
+ // test means "test for for file endings"
51
+ test: /.scss$/,
52
+ use: [
53
+ {
54
+ loader: "style-loader",
55
+ options: {
56
+ hmr: true
57
+ }
58
+ },
59
+ {
60
+ loader: "css-loader",
61
+ options: {
62
+ sourceMap: true, // set to false to speed up hot reloads
63
+ minimize: false // set to false to speed up hot reloads
64
+ }
65
+ },
66
+ {
67
+ loader: "sass-loader",
68
+ options: {
69
+ includePaths: [path.resolve(__dirname, '<%= stylesheets_directory %>')],
70
+ sourceMap: true // set to false to speed up hot reloads
71
+ }
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ // loader for .css files
77
+ test: /.css$/,
78
+ use: [
79
+ {
80
+ loader: "style-loader",
81
+ options: {
82
+ hmr: true
83
+ }
84
+ },
85
+ {
86
+ loader: "css-loader",
87
+ options: {
88
+ sourceMap: true, // set to false to speed up hot reloads
89
+ minimize: false // set to false to speed up hot reloads
90
+ }
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ test: /.(png|svg|jpg|gif)$/,
96
+ use: [
97
+ 'file-loader'
98
+ ]
99
+ },
100
+ {
101
+ test: /.(woff|woff2|eot|ttf|otf)$/,
102
+ use: [
103
+ 'file-loader'
104
+ ]
105
+ },
106
+ {
107
+ // opal-webpack-loader will compile and include ruby files in the pack
108
+ test: /.(rb|js.rb)$/,
109
+ use: [
110
+ {
111
+ loader: 'opal-webpack-loader',
112
+ options: {
113
+ sourceMap: true
114
+ }
115
+ }
116
+ ]
117
+ }
118
+ ]
119
+ },
120
+ // configuration for webpack-dev-server
121
+ devServer: {
122
+ open: false,
123
+ lazy: false,
124
+ port: 3035,
125
+ hot: true,
126
+ // hotOnly: true,
127
+ inline: true,
128
+ https: false,
129
+ disableHostCheck: true,
130
+ headers: {
131
+ "Access-Control-Allow-Origin": "*",
132
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
133
+ "Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
134
+ },
135
+ watchOptions: {
136
+ // in case of problems with hot reloading uncomment the following two lines:
137
+ // aggregateTimeout: 250,
138
+ // poll: 50,
139
+ ignored: /\bnode_modules\b/
140
+ },
141
+ contentBase: path.resolve(__dirname, 'public')
142
+ // watchContentBase: true
143
+ }
144
+ };
145
+