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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b195faad06e86f99145977d3551f71b22ff4717f9c3750572061a18e88b57c0e
|
4
|
+
data.tar.gz: 943969a8513c3acf8d28da2039a88d418f443c136fab28e3ddf689883b6e9c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 565979248f76810bcb6783a18dac93276ea69bc6ca45bdeadf2b5c055a21e56f1829d83f3df4ec9ca29e5cea1355a4996efcf9c572fbd6d26429665499a5020f
|
7
|
+
data.tar.gz: 68a3c55de9b28a6ca91a6e98a68e5920cd5ac314aab15e38db09954ea8d9cf311970c768640d9251b4d10fd2c44f63d76a89d09f9ac07ee98f5ee2fdb599770e
|
data/lib/opal-webpack-loader.rb
CHANGED
@@ -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
|
-
|
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
|
4
|
-
|
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}
|
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,12 +1,11 @@
|
|
1
1
|
module OpalWebpackLoader
|
2
2
|
module ViewHelper
|
3
|
-
def
|
4
|
-
|
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}
|
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
|