webpack_native 0.4.9 → 0.5.2

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: 74b744bdc5f7b9675d782b511e60e8630865466b94fb20d885a9228d425c60f9
4
- data.tar.gz: 754022a887f2a5381f47d3494f5e81e79dd93ebb624cef512eca3f659eeafc63
3
+ metadata.gz: c43ea964f3ee6c2e1bf0d48cf266d9fd06c066ab7e61d9a07f1178d5eb177398
4
+ data.tar.gz: e7c249c8851f04ee278540b4db1a53b3ecf87ef242578b38c12dfd1a0477f7f9
5
5
  SHA512:
6
- metadata.gz: eb9ff0c576ae30ea0d83a0abff8ff1d01f4c8fb2272d5ca8f42ee983358dc6262b3194db90651e90dceea1c88ae43f265f37b731013552e58f733a4f85fdf0e9
7
- data.tar.gz: a46151740f88360538521531b9a434bef767faff6b14605ee36f4d666625651dece5cf3f43467e301167932e8e3ee02c5e04d867860032ef7c4ee3bfa79dd77d
6
+ metadata.gz: bde4f040a35fafe117007e4dc40aa5fdf5497ba4fe3afb19922f5c617d6fc17aec3c4b168e35d3c7956ecdd223503e379d10d3ff2b37ff0ee5a43cf3edd86b9c
7
+ data.tar.gz: b08b606119d3578cdabc440385bc7ab1be58c67a796a5fe9335c95625734dbec6c1e996453c984bb51bd3fed13a3f03dd41bbd5966b57d10400ad30cde6be312
@@ -57,7 +57,7 @@ module.exports = (env, options) => {
57
57
  ],
58
58
  },
59
59
  {
60
- test: /\.(png|jpg|gif|svg)$/i,
60
+ test: /\.(png|jpg|jpeg|gif|svg|ttf|woff2|woff|eot|webmanifest)$/i,
61
61
  use: [
62
62
  {
63
63
  loader: 'url-loader',
@@ -115,6 +115,6 @@ module.exports = (env, options) => {
115
115
  // ]
116
116
  // }
117
117
 
118
- }
118
+ };
119
119
 
120
- }
120
+ };
@@ -17,7 +17,8 @@ class WebpackNative::Railtie < ::Rails::Railtie
17
17
  end
18
18
 
19
19
  initializer "webpack_native_set_manifest" do
20
- if Rails.env.production?
20
+
21
+ if Rails.env.production? # on production only
21
22
 
22
23
  # create public/webpack_native if it doesn't exist:
23
24
 
@@ -39,6 +40,7 @@ class WebpackNative::Railtie < ::Rails::Railtie
39
40
  Rails.configuration.x.webpack_native.webpack_manifest_file = WebpackNative::WebpackNativeHelper.load_webpack_manifest
40
41
 
41
42
  end
43
+
42
44
  end
43
45
 
44
46
  def start_webpack
@@ -1,3 +1,3 @@
1
1
  module WebpackNative
2
- VERSION = "0.4.9"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  module WebpackNative::WebpackNativeHelper
2
-
2
+
3
3
  def webpack_stylesheet_tag(asset, **html_options)
4
4
  html_options = html_options.merge(
5
5
  href: webpack_stylesheet_path(asset),
@@ -43,6 +43,66 @@ module WebpackNative::WebpackNativeHelper
43
43
  def webpack_image_path(image, **options)
44
44
  image_path(webpack_native_lookup(image), **options)
45
45
  end
46
+
47
+ # ====== Favicon helpers ======
48
+ # usage:
49
+ # <%= webpack_favicons('apple-touch-icon.png', 'favicon-32x32.png', 'favicon-16x16.png') %>
50
+ # <%= webpack_webmanifest('manifest.webmanifest') %>
51
+
52
+ # result:
53
+ #<link rel="apple-touch-icon" sizes="180x180" href="/webpack_native/apple-touch-icon.png">
54
+ #<link rel="icon" type="image/png" sizes="32x32" href="/webpack_native/favicon-32x32.png">
55
+ #<link rel="icon" type="image/png" sizes="16x16" href="/webpack_native/favicon-16x16.png">
56
+ #<link rel="manifest" href="/webpack_native/site.webmanifest">
57
+
58
+ def webpack_favicons(*args)
59
+ tags = []
60
+ args.each do |favicon|
61
+
62
+ filename = File.basename(favicon, ".*") # exclude the extension
63
+ ext = File.extname(favicon)
64
+
65
+ if ext == '.webmanifest'
66
+ manifest = favicon
67
+ html_options = {
68
+ rel: 'manifest',
69
+ href: webpack_native_lookup(manifest)
70
+ }
71
+
72
+ else
73
+ mimetypes = {
74
+ '.png' => 'image/png',
75
+ '.jpg' => 'image/jpg',
76
+ '.jpeg' => 'image/jpeg',
77
+ '.webp' => 'image/webp',
78
+ '.tiff' => 'image/tiff',
79
+ '.svg' => 'image/svg+xml',
80
+ '.ico' => 'image/x-icon'
81
+ }
82
+
83
+ html_options = {
84
+ rel: filename == 'apple-touch-icon' ? 'apple-touch-icon' : 'icon',
85
+ type: mimetypes[ext],
86
+ href: webpack_native_lookup(favicon)
87
+ }
88
+
89
+ sizes = filename[/(.+)?([0-9]{2,3}x[0-9]{2,3})(.+)?/, 2]
90
+
91
+ sizes = '180×180' if filename == 'apple-touch-icon'
92
+
93
+ html_options = html_options.merge({sizes: sizes}) unless sizes.nil?
94
+
95
+ end
96
+
97
+ tags << tag.link(html_options)
98
+
99
+ end
100
+
101
+ return tags.join.html_safe
102
+
103
+ end
104
+
105
+ # ====== End favicon helpers ======
46
106
 
47
107
  private
48
108
 
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.4.9
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - scratchoo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-20 00:00:00.000000000 Z
11
+ date: 2021-03-13 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!