opal-webpack-loader 0.4.4 → 0.5.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: 7aa55937b3915292ac13d9c66b4bf9f6f737ad5836afc702272ea97614045730
4
- data.tar.gz: 00f9d0764d203b8303b7b1691481cdebad1a47b158e31f99d64b65405ab46de4
3
+ metadata.gz: b195faad06e86f99145977d3551f71b22ff4717f9c3750572061a18e88b57c0e
4
+ data.tar.gz: 943969a8513c3acf8d28da2039a88d418f443c136fab28e3ddf689883b6e9c95
5
5
  SHA512:
6
- metadata.gz: bf301a2b0c3810e3f3a42fa2eb4338f9a5274de6e1fd786fe29de4906700be1c5669fa6259dbdfdce55d8752b178329ee0f0814f9ff93152b15c6985ffa63164
7
- data.tar.gz: 46f32a4d6ca22642aff5bdf70a16ea069b03826c7e11c1653eab1a7c6220bb658dcbffbb5a52ab6e207638bcf8f1784c6100472e40a3265efa8ca6225aa30f86
6
+ metadata.gz: 565979248f76810bcb6783a18dac93276ea69bc6ca45bdeadf2b5c055a21e56f1829d83f3df4ec9ca29e5cea1355a4996efcf9c572fbd6d26429665499a5020f
7
+ data.tar.gz: 68a3c55de9b28a6ca91a6e98a68e5920cd5ac314aab15e38db09954ea8d9cf311970c768640d9251b4d10fd2c44f63d76a89d09f9ac07ee98f5ee2fdb599770e
@@ -18,6 +18,14 @@ module OpalWebpackLoader
18
18
  def self.client_asset_path=(path)
19
19
  @client_asset_path = path
20
20
  end
21
+
22
+ def self.use_manifest
23
+ @use_manifest
24
+ end
25
+
26
+ def self.use_manifest=(bool)
27
+ @use_manifest = bool
28
+ end
21
29
  end
22
30
 
23
31
  if defined? Rails
@@ -27,13 +35,18 @@ else
27
35
  end
28
36
 
29
37
  OpalWebpackLoader.manifest_path = File.join(Dir.getwd, 'public', 'assets', 'manifest.json')
30
- OpalWebpackLoader.client_asset_path = '/assets'
38
+ OpalWebpackLoader.client_asset_path = 'http://localhost:3035/assets/'
39
+ OpalWebpackLoader.use_manifest = false
31
40
 
32
41
  npm = `which npm`.chop
33
42
 
34
43
  if npm != ''
35
44
  bin_dir = `npm bin`.chop
36
- owl_npm_version = `#{bin_dir}/opal-webpack-loader-npm-version`.chop
45
+ begin
46
+ owl_npm_version = `#{bin_dir}/opal-webpack-loader-npm-version`.chop
47
+ rescue
48
+ owl_npm_version = nil
49
+ end
37
50
 
38
51
  if owl_npm_version != OpalWebpackLoader::VERSION
39
52
  raise "opal-webpack-loader: Incorrect version of npm package found or npm package not installed.\n" +
@@ -42,5 +55,5 @@ if npm != ''
42
55
  "\tor with yarn:\tyarn add opal-webpack-loader@#{OpalWebpackLoader::VERSION} --dev\n"
43
56
  end
44
57
  else
45
- puts "opal-webpack-loader: Unable to check npm package version. Please check your npm installation."
58
+ STDERR.puts "opal-webpack-loader: Unable to check npm package version. Please check your npm installation."
46
59
  end
@@ -1,13 +1,12 @@
1
1
  module OpalWebpackLoader
2
2
  module RailsViewHelper
3
- def owl_include_tag(path)
4
- case Rails.env
5
- when 'development'
6
- javascript_include_tag("http://localhost:3035#{OpalWebpackLoader.client_asset_path}/#{path}")
7
- else
3
+ def owl_script_tag(path)
4
+ if OpalWebpackLoader.use_manifest
8
5
  asset = path.split('/').last
9
6
  asset_path = OpalWebpackLoader::Manifest.lookup_path_for(asset)
10
- javascript_include_tag("#{OpalWebpackLoader.client_asset_path}/#{asset_path}")
7
+ javascript_include_tag("#{OpalWebpackLoader.client_asset_path}#{asset_path}")
8
+ else
9
+ javascript_include_tag("#{OpalWebpackLoader.client_asset_path}#{path}")
11
10
  end
12
11
  end
13
12
  end
@@ -1,3 +1,3 @@
1
1
  module OpalWebpackLoader
2
- VERSION="0.4.4"
2
+ VERSION="0.5.0"
3
3
  end
@@ -1,12 +1,11 @@
1
1
  module OpalWebpackLoader
2
2
  module ViewHelper
3
- def owl_include_tag(path, env = 'development')
4
- case env
5
- when 'development'
6
- "<script type=\"application/javascript\" src=\"http://localhost:3035#{OpalWebpackLoader.client_asset_path}/#{path}\"></script>"
7
- else
3
+ def owl_script_tag(path)
4
+ if OpalWebpackLoader.use_manifest
8
5
  asset_path = OpalWebpackLoader::Manifest.lookup_path_for(path)
9
- "<script type=\"application/javascript\" src=\"#{OpalWebpackLoader.client_asset_path}/#{asset_path}\"></script>"
6
+ "<script type=\"application/javascript\" src=\"#{OpalWebpackLoader.client_asset_path}#{asset_path}\"></script>"
7
+ else
8
+ "<script type=\"application/javascript\" src=\"#{OpalWebpackLoader.client_asset_path}#{path}\"></script>"
10
9
  end
11
10
  end
12
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-webpack-loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann