webpack_native 0.2.9 → 0.3.7

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: f7f1a68d09162386737acf2c548fa7f5b15f41b583d442d11d3a4f565f79c9c8
4
- data.tar.gz: 2f0e25eb8bd5716680a903b5fefe38dc0f798971b43755b452f67bba7b8057a1
3
+ metadata.gz: 364ab7abe793fccf23fb730c0c16ab8d3a7a53082ad611efe8668ea37f79a4f6
4
+ data.tar.gz: 36b17b11cad6492ca2b4c58b0de76e941fada353460d832af1c2fd53663f4083
5
5
  SHA512:
6
- metadata.gz: c7c21e4f8779da0840b67d4521ee2b6860cfacdd8378c42f0f4442200e73a7f24dfe36fcf9b30cc4aa9b16666f886d65c9d31fd7de92f03d286771f60b400c2f
7
- data.tar.gz: acf37985bcfded4ad4f3f61ab63aa7844145200004441555517d301d119b8316f5e7dade17ccdcab9c0ee1ac7a12caa737839a289aff477964c5f58fd0320386
6
+ metadata.gz: '008430165b30c2783511099bbbc208e708418836f32563e4f5104d565d059d80e573964c9912ed0f34742ece9bfe548527139cbc8970ecd79cdb347f05d906f2'
7
+ data.tar.gz: bacc4f6434cbd676016ca6f5a8a44772f8483e123e845073935f1e5347834c1f7d48eb0574ad167915dd40e373644d9d80d50f9e52a54a7bfffbc167cc4eb80c
@@ -36,10 +36,22 @@ class WebpackNative::InstallGenerator < Rails::Generators::Base
36
36
  # more colors can be found at: https://stackoverflow.com/questions/1489183/colorized-ruby-output-to-the-terminal
37
37
 
38
38
  Dir.chdir "#{Rails.root}/app/webpack_native" do
39
- %x{ npm install }
39
+ %x{ yarn install } # 88% + 80% faster than npm install
40
40
  end
41
41
  end
42
42
 
43
+ def add_node_modules_to_gitignore
44
+ puts "\nAdding /app/webpack_native/node_modules to .gitignore...\n"
45
+ folder_to_ignore = '/app/webpack_native/node_modules'
46
+ # add webpack_native's node_modules folder to gitignore if it isn't added yet
47
+ %x{ grep -qxF '#{folder_to_ignore}' .gitignore || echo '#{folder_to_ignore}' >> .gitignore }
48
+ puts "=> Done!"
49
+ end
50
+
51
+ def output_installation_finished_msg
52
+ puts "\n\e[32m*** WebpackNative - installation finished. ***\e[0m\n"
53
+ end
54
+
43
55
  # This step was moved to railtie class, it's better to run webpack within the gem after initialize than injecting the code in config.ru
44
56
  # (4) When the server starts, start webpack in a separate thread (this should be done in config.ru)
45
57
  # def inject_webpack_command
@@ -6,6 +6,7 @@ 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
+ %x{ yarn install }
9
10
  result = %x{ npm run build:prod }
10
11
  puts "\n"
11
12
  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
@@ -9,8 +9,14 @@ class WebpackNative::Railtie < ::Rails::Railtie
9
9
 
10
10
  initializer "webpack_native_set_manifest" do
11
11
  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
12
+ manifest_path = "#{Rails.root}/public/webpack_native/manifest.json"
13
+ # 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
14
+ if !File.file?(manifest_path)
15
+ #FileUtils.touch
16
+ File.write manifest_path, "{}"
17
+ end
18
+ require_relative 'webpack_native_helper'
19
+ Rails.configuration.x.webpack_native.webpack_manifest_file = WebpackNative::WebpackNativeHelper.load_webpack_manifest
14
20
  end
15
21
  end
16
22
 
@@ -26,7 +32,7 @@ class WebpackNative::Railtie < ::Rails::Railtie
26
32
 
27
33
  initializer "run_webpack_build_cmd" do
28
34
  config.after_initialize do
29
- if defined?(Rails::Server)
35
+ if defined?(Rails::Server) && Rails.env.development?
30
36
  Thread.new { start_webpack }
31
37
  end
32
38
  end
@@ -1,3 +1,3 @@
1
1
  module WebpackNative
2
- VERSION = "0.2.9"
2
+ VERSION = "0.3.7"
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.2.9
4
+ version: 0.3.7
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-03 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