railspacker 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9f23b290d0fbbfdd913cea567f5ca3062e253c8a43524670a99783b0b12d0dc
4
- data.tar.gz: 402e2a379988f69fbf9d64487baed592f8406429a2e223d2e2bbc0447f8b2d7b
3
+ metadata.gz: bed5e14cdffea7ec2d8425d59c64578c1c4625d803c3d9a08c7a01fe56ae8c7e
4
+ data.tar.gz: 28856f38d1300804d55f8b9eeca10a8507a8dd9edf48853f26f99a179e776fb9
5
5
  SHA512:
6
- metadata.gz: b14e4f786834a25cadb5063e177f47bc9eeee99bdbe4904d1eb162adb675d73ec45ab381f7a267371b5564b031afcc4afa64978497c3e22596228c90f86d8ce8
7
- data.tar.gz: 661aaafe410e8967d77c2072692d27a4d01055e2149cd9bc468cebf752aaadcb519cee201000fe1914d9617354615aae12d47360997012afb1b30e32e75d25cb
6
+ metadata.gz: 38cbd0eabb7a6568098a1cd94f040a506ccf199ba8e55ff01a0fba41eb7c051501cbb3f8eb551d9368199150206767ca99853162059333fb12b6eb72da1f2a73
7
+ data.tar.gz: 6b5cc2f3e10f999da798ecd2fae0e2eebb16f88659d233c1473e7ae6c9e458c3c338bc2948f66b364c014072e64b93f3ff2ca510e5c785e3fe3a98e2843afdb8
@@ -1,6 +1,9 @@
1
- # `build` script will run before the `assets:precompile` task
1
+ # Script that will run run before the `assets:precompile` task
2
2
  # Railspacker.before_assets_precompile_script = 'build'
3
3
 
4
+ # Change this if you need change output path returned by manifest.json
5
+ # Railspacker.source = ->(filename) { filename }
6
+
4
7
  Railspacker.manifest = case Rails.env
5
8
  when 'development'
6
9
  Railspacker::Manifest::DevServer.new(url: 'http://localhost:3001')
@@ -8,4 +11,4 @@ when 'test'
8
11
  Railspacker::Manifest::Build.new(public_path: 'packs-test')
9
12
  when 'production'
10
13
  Railspacker::Manifest::Build.new(public_path: 'packs')
11
- end
14
+ end
@@ -14,33 +14,54 @@ module.exports = (env) => {
14
14
  config.entry = {
15
15
  app: './app/webpack/index.js'
16
16
  };
17
+
17
18
  config.plugins = [
18
19
  // Generate a manifest.json to output. Is requred to Railspacker.
19
20
  new ManifestPlugin(),
20
21
 
21
22
  // Clean output directory before builds
22
23
  new CleanWebpackPlugin([outputPath]),
23
-
24
- // Enables Hot Module Replacement, otherwise known as HMR.
25
- new webpack.HotModuleReplacementPlugin()
26
24
  ];
25
+
27
26
  config.output = {
28
27
  filename: '[name].js',
29
28
  path: path.resolve(__dirname, outputPath)
30
29
  };
31
30
 
32
- if (env === 'development' || env === 'test') {
31
+ // development environment
32
+ if (env == 'development') {
33
33
  config.mode = 'development'
34
34
  config.devtool = 'inline-source-map'
35
+
36
+ // This set of options is picked up by webpack-dev-server
35
37
  config.devServer = {
36
38
  contentBase: path.resolve(__dirname, 'app/webpack'),
37
39
  port: 3001,
38
- hot: true
40
+ hot: true,
41
+ headers: {
42
+ "Access-Control-Allow-Origin": "*"
43
+ }
39
44
  }
45
+
46
+ config.plugins = config.plugins.concat([
47
+ // Enables Hot Module Replacement, otherwise known as HMR.
48
+ new webpack.HotModuleReplacementPlugin()
49
+ ])
50
+
51
+ config.output.publicPath = 'http://localhost:3001/'
52
+ };
53
+
54
+ // test environment
55
+ if (env === 'test') {
56
+ config.mode = 'development'
57
+ config.devtool = 'inline-source-map'
58
+ config.output.publicPath = 'packs-test/'
40
59
  };
41
60
 
61
+ // production environment
42
62
  if (env === 'production') {
43
63
  config.mode = 'production'
64
+ config.output.publicPath = 'packs/'
44
65
  };
45
66
 
46
67
  return config;
@@ -5,6 +5,7 @@ require "railspacker/manifest/dev_server"
5
5
  module Railspacker
6
6
  mattr_accessor :manifest
7
7
  mattr_accessor :before_assets_precompile_script, default: 'build'
8
+ mattr_accessor :source, default: ->(filename) { filename }
8
9
 
9
10
  def self.run(name)
10
11
  system("yarn run #{name}")
@@ -10,8 +10,8 @@ module Railspacker
10
10
  if !manifest.key?(name)
11
11
  raise "Pack not found in manifest.json: #{name}"
12
12
  end
13
-
14
- [Railspacker.manifest.path_to, manifest[name]].join('/')
13
+
14
+ Railspacker.source.call(manifest[name])
15
15
  end
16
16
  end
17
17
  end
@@ -5,9 +5,5 @@ module Railspacker::Manifest
5
5
 
6
6
  JSON.parse File.read(file)
7
7
  end
8
-
9
- def path_to
10
- Pathname.new('/').join(public_path)
11
- end
12
8
  end
13
9
  end
@@ -7,9 +7,5 @@ module Railspacker::Manifest
7
7
 
8
8
  JSON.parse Net::HTTP.get(uri)
9
9
  end
10
-
11
- def path_to
12
- url
13
- end
14
10
  end
15
11
  end
@@ -1,3 +1,3 @@
1
1
  module Railspacker
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railspacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Magro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-01 00:00:00.000000000 Z
11
+ date: 2019-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails