webpack_native 0.3.1 → 0.3.9

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: 9b3b3ad0a180744aabbe2c81403541649fcfd7377952df64296b4f8736713805
4
- data.tar.gz: 7729c2172152628580405716518b54152d58d9e387d8926de1fa86a1ff25fe38
3
+ metadata.gz: 898bb9c4f771b2ab8cd955eb1fb4905dae5390fcbb99e4fffc2ff8aa87da841d
4
+ data.tar.gz: 9fff199c9312a34abfc2bb9fb762ac3870a657ebeab9b1f7d558abf581654c7e
5
5
  SHA512:
6
- metadata.gz: 148c2fabcc3382ca3f2cb45988105ad3c252e5cbdc0b0fda812f2d797fee4ec7200c3cf7c871d922f32a6b2e5226077ad6d03f0a6a7d1325fca8be455238305c
7
- data.tar.gz: c14e87acc08352fe79e1b9a6ea99fe441b875d275654a3a4d2fade97a4a898939ed6b9b7fc6e1e6a5d8d99a843d4e4fe703d1e03e9c8e23ad58efc912a95ee26
6
+ metadata.gz: dfd7c8b1a9915002b2c837422f78c7985b21775a527ecddc33be4395ffdefbc47f7278f1b2819996a897f396e5302af11b7b3dace092a89a1f4fb513e0dbc472
7
+ data.tar.gz: d29a2de898cba30e1e9c3769e57986c7115999a632631a6bb6a3b06cf1da5e779b705ed1831910b25da06c8ade19048d2f12cb02837a63d3b1f95305b241d639
@@ -6,6 +6,8 @@ class WebpackNative::DevGenerator < Rails::Generators::Base
6
6
 
7
7
  Mutex.new.synchronize do
8
8
  Dir.chdir "#{Rails.root}/app/webpack_native" do
9
+ Dir.mkdir('src/images') unless Dir.exist?('src/images')
10
+ %x{ yarn install }
9
11
  result = %x{ npm run build:dev }
10
12
  puts "\n"
11
13
  puts result
@@ -6,6 +6,8 @@ class WebpackNative::ProdGenerator < Rails::Generators::Base
6
6
 
7
7
  Mutex.new.synchronize do
8
8
  Dir.chdir "#{Rails.root}/app/webpack_native" do
9
+ Dir.mkdir('src/images') unless Dir.exist?('src/images')
10
+ %x{ yarn install }
9
11
  result = %x{ npm run build:prod }
10
12
  puts "\n"
11
13
  puts result
@@ -1,5 +1,5 @@
1
1
  require "webpack_native/version"
2
- require 'generators/webpack_native/templates/webpack_native_helper'
2
+ require 'webpack_native/webpack_native_helper'
3
3
  require 'webpack_native/runner'
4
4
  require 'webpack_native/railtie' if defined?(Rails)
5
5
 
@@ -16,5 +16,5 @@ end
16
16
 
17
17
  # include WebpackNativeHelper for ActionView
18
18
  ActiveSupport.on_load :action_view do
19
- ::ActionView::Base.send :include, WebpackNativeHelper
19
+ ::ActionView::Base.send :include, WebpackNative::WebpackNativeHelper
20
20
  end
@@ -7,10 +7,24 @@ class WebpackNative::Railtie < ::Rails::Railtie
7
7
  WebpackNative.logger = ActiveSupport::Logger.new(STDOUT)
8
8
  end
9
9
 
10
+ # Zeitwerk raise an error: set_autoloads_in_dir': wrong constant name Path-dirname inferred by Module from directory (Zeitwerk::NameError) ---> app/webpack_native/node_modules/path-dirname
11
+ # to prevent Zeitwerk from eager loading webpack_native folder we use this:
12
+ initializer "zeitwerk_prevent_loading_webpack_native" do
13
+ if Rails.autoloaders.zeitwerk_enabled?
14
+ Rails.autoloaders.main.ignore(Rails.root.join('app/webpack_native'))
15
+ end
16
+ end
17
+
10
18
  initializer "webpack_native_set_manifest" do
11
19
  if Rails.env.production?
12
- require_relative 'generators/webpack_native/templates/webpack_native_helper.rb'
13
- Rails.configuration.x.webpack_native.webpack_manifest_file = WebpackNativeHelper.load_webpack_manifest
20
+ manifest_path = "#{Rails.root}/public/webpack_native/manifest.json"
21
+ # create manifest.json file if it doesn't exist with an empty json {} to prevent raising error in WebpackNativeHelper.load_webpack_manifest if a restart of a service happen (i.e delayed_job restart) that causes rails to load
22
+ if !File.file?(manifest_path)
23
+ #FileUtils.touch
24
+ File.write manifest_path, "{}"
25
+ end
26
+ require_relative 'webpack_native_helper'
27
+ Rails.configuration.x.webpack_native.webpack_manifest_file = WebpackNative::WebpackNativeHelper.load_webpack_manifest
14
28
  end
15
29
  end
16
30
 
@@ -26,7 +40,7 @@ class WebpackNative::Railtie < ::Rails::Railtie
26
40
 
27
41
  initializer "run_webpack_build_cmd" do
28
42
  config.after_initialize do
29
- if defined?(Rails::Server)
43
+ if defined?(Rails::Server) && Rails.env.development?
30
44
  Thread.new { start_webpack }
31
45
  end
32
46
  end
@@ -1,3 +1,3 @@
1
1
  module WebpackNative
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -1,4 +1,4 @@
1
- module WebpackNativeHelper
1
+ module WebpackNative::WebpackNativeHelper
2
2
 
3
3
  def webpack_stylesheet_url(asset, **html_options)
4
4
  html_options = html_options.merge(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpack_native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - scratchoo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2020-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use vanilla webpack to manage your assets efficiently, no webpacker or
14
14
  asset pipeline anymore!
@@ -19,18 +19,17 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - lib/generators/webpack_native/dev_generator.rb
22
- - lib/generators/webpack_native/helper_generator.rb
23
22
  - lib/generators/webpack_native/install_generator.rb
24
23
  - lib/generators/webpack_native/prod_generator.rb
25
24
  - lib/generators/webpack_native/templates/webpack_native/package.json
26
25
  - lib/generators/webpack_native/templates/webpack_native/src/javascripts/application.js
27
26
  - lib/generators/webpack_native/templates/webpack_native/src/stylesheets/application.scss
28
27
  - lib/generators/webpack_native/templates/webpack_native/webpack.config.js
29
- - lib/generators/webpack_native/templates/webpack_native_helper.rb
30
28
  - lib/webpack_native.rb
31
29
  - lib/webpack_native/railtie.rb
32
30
  - lib/webpack_native/runner.rb
33
31
  - lib/webpack_native/version.rb
32
+ - lib/webpack_native/webpack_native_helper.rb
34
33
  homepage: https://www.github.com/scratchoo/webpack_native
35
34
  licenses:
36
35
  - MIT
@@ -1,22 +0,0 @@
1
- class WebpackNative::HelperGenerator < Rails::Generators::Base
2
-
3
- # our templates location:
4
- source_root File.expand_path('templates', __dir__)
5
-
6
- #this is used to generate/add the helper file to rails project
7
- def add_webpack_helper
8
- template "webpack_native_helper.rb", File.join("app/helpers", "webpack_native_helper.rb")
9
- end
10
-
11
- # include_webpack_helper in application_controller.rb
12
- def include_webpack_helper
13
- application_controller = "#{Rails.root}/app/controllers/application_controller.rb"
14
-
15
- include_webpack_helper = "\n\tinclude WebpackNativeHelper"
16
-
17
- class_declaration = 'class ApplicationController < ActionController::Base'
18
-
19
- inject_into_file application_controller, include_webpack_helper, after: class_declaration
20
- end
21
-
22
- end