jetpacker 0.1.0 → 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.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintignore +4 -0
  3. data/.eslintrc.js +14 -0
  4. data/.gitignore +11 -11
  5. data/.node-version +1 -0
  6. data/.rubocop.yml +125 -0
  7. data/.travis.yml +54 -5
  8. data/CHANGELOG.jetpacker.md +7 -0
  9. data/CHANGELOG.md +1000 -0
  10. data/CONTRIBUTING.md +33 -0
  11. data/Gemfile +9 -3
  12. data/Gemfile.lock +157 -21
  13. data/MIT-LICENSE +20 -0
  14. data/README.md +671 -16
  15. data/Rakefile +8 -3
  16. data/docs/assets.md +119 -0
  17. data/docs/cloud9.md +310 -0
  18. data/docs/css.md +253 -0
  19. data/docs/deployment.md +130 -0
  20. data/docs/docker.md +68 -0
  21. data/docs/engines.md +200 -0
  22. data/docs/env.md +65 -0
  23. data/docs/es6.md +72 -0
  24. data/docs/folder-structure.md +66 -0
  25. data/docs/misc.md +23 -0
  26. data/docs/props.md +223 -0
  27. data/docs/testing.md +137 -0
  28. data/docs/troubleshooting.md +156 -0
  29. data/docs/typescript.md +126 -0
  30. data/docs/v4-upgrade.md +142 -0
  31. data/docs/webpack-dev-server.md +92 -0
  32. data/docs/webpack.md +364 -0
  33. data/docs/yarn.md +23 -0
  34. data/gemfiles/Gemfile-rails-edge +12 -0
  35. data/gemfiles/Gemfile-rails.4.2.x +9 -0
  36. data/gemfiles/Gemfile-rails.5.0.x +9 -0
  37. data/gemfiles/Gemfile-rails.5.1.x +9 -0
  38. data/gemfiles/Gemfile-rails.5.2.x +9 -0
  39. data/gemfiles/Gemfile-rails.6.0.x +9 -0
  40. data/jetpacker.gemspec +28 -22
  41. data/lib/install/angular.rb +23 -0
  42. data/lib/install/bin/webpack +18 -0
  43. data/lib/install/bin/webpack-dev-server +18 -0
  44. data/lib/install/binstubs.rb +4 -0
  45. data/lib/install/coffee.rb +25 -0
  46. data/lib/install/config/.browserslistrc +1 -0
  47. data/lib/install/config/babel.config.js +72 -0
  48. data/lib/install/config/postcss.config.js +12 -0
  49. data/lib/install/config/webpack/development.js +5 -0
  50. data/lib/install/config/webpack/environment.js +3 -0
  51. data/lib/install/config/webpack/production.js +5 -0
  52. data/lib/install/config/webpack/test.js +5 -0
  53. data/lib/install/config/webpacker.yml +96 -0
  54. data/lib/install/elm.rb +39 -0
  55. data/lib/install/erb.rb +25 -0
  56. data/lib/install/examples/angular/hello_angular.js +7 -0
  57. data/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
  58. data/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
  59. data/lib/install/examples/angular/hello_angular/index.ts +8 -0
  60. data/lib/install/examples/angular/hello_angular/polyfills.ts +73 -0
  61. data/lib/install/examples/coffee/hello_coffee.coffee +4 -0
  62. data/lib/install/examples/elm/Main.elm +55 -0
  63. data/lib/install/examples/elm/hello_elm.js +16 -0
  64. data/lib/install/examples/erb/hello_erb.js.erb +6 -0
  65. data/lib/install/examples/react/babel.config.js +87 -0
  66. data/lib/install/examples/react/hello_react.jsx +26 -0
  67. data/lib/install/examples/react/tsconfig.json +20 -0
  68. data/lib/install/examples/stimulus/application.js +1 -0
  69. data/lib/install/examples/stimulus/controllers/hello_controller.js +18 -0
  70. data/lib/install/examples/stimulus/controllers/index.js +9 -0
  71. data/lib/install/examples/svelte/app.svelte +11 -0
  72. data/lib/install/examples/svelte/hello_svelte.js +20 -0
  73. data/lib/install/examples/typescript/hello_typescript.ts +4 -0
  74. data/lib/install/examples/typescript/tsconfig.json +23 -0
  75. data/lib/install/examples/vue/app.vue +22 -0
  76. data/lib/install/examples/vue/hello_vue.js +72 -0
  77. data/lib/install/javascript/packs/application.js +18 -0
  78. data/lib/install/loaders/coffee.js +6 -0
  79. data/lib/install/loaders/elm.js +25 -0
  80. data/lib/install/loaders/erb.js +11 -0
  81. data/lib/install/loaders/svelte.js +9 -0
  82. data/lib/install/loaders/typescript.js +11 -0
  83. data/lib/install/loaders/vue.js +6 -0
  84. data/lib/install/react.rb +18 -0
  85. data/lib/install/stimulus.rb +12 -0
  86. data/lib/install/svelte.rb +29 -0
  87. data/lib/install/template.rb +55 -0
  88. data/lib/install/typescript.rb +46 -0
  89. data/lib/install/vue.rb +49 -0
  90. data/lib/jetpacker/version.rb +2 -1
  91. data/lib/tasks/installers.rake +37 -0
  92. data/lib/tasks/webpacker.rake +28 -0
  93. data/lib/tasks/webpacker/binstubs.rake +11 -0
  94. data/lib/tasks/webpacker/check_binstubs.rake +12 -0
  95. data/lib/tasks/webpacker/check_node.rake +24 -0
  96. data/lib/tasks/webpacker/check_yarn.rake +24 -0
  97. data/lib/tasks/webpacker/clean.rake +21 -0
  98. data/lib/tasks/webpacker/clobber.rake +16 -0
  99. data/lib/tasks/webpacker/compile.rake +43 -0
  100. data/lib/tasks/webpacker/info.rake +20 -0
  101. data/lib/tasks/webpacker/install.rake +13 -0
  102. data/lib/tasks/webpacker/verify_install.rake +13 -0
  103. data/lib/tasks/webpacker/yarn_install.rake +21 -0
  104. data/lib/webpacker.rb +46 -0
  105. data/lib/webpacker/commands.rb +50 -0
  106. data/lib/webpacker/compiler.rb +107 -0
  107. data/lib/webpacker/configuration.rb +113 -0
  108. data/lib/webpacker/dev_server.rb +66 -0
  109. data/lib/webpacker/dev_server_proxy.rb +31 -0
  110. data/lib/webpacker/dev_server_runner.rb +72 -0
  111. data/lib/webpacker/env.rb +39 -0
  112. data/lib/webpacker/helper.rb +176 -0
  113. data/lib/webpacker/instance.rb +37 -0
  114. data/lib/webpacker/manifest.rb +118 -0
  115. data/lib/webpacker/railtie.rb +98 -0
  116. data/lib/webpacker/rake_tasks.rb +6 -0
  117. data/lib/webpacker/runner.rb +22 -0
  118. data/lib/webpacker/version.rb +4 -0
  119. data/lib/webpacker/webpack_runner.rb +32 -0
  120. data/package.json +82 -0
  121. data/package/__tests__/config.js +55 -0
  122. data/package/__tests__/dev_server.js +43 -0
  123. data/package/__tests__/development.js +30 -0
  124. data/package/__tests__/env.js +46 -0
  125. data/package/__tests__/production.js +29 -0
  126. data/package/__tests__/staging.js +29 -0
  127. data/package/__tests__/test.js +26 -0
  128. data/package/config.js +37 -0
  129. data/package/config_types/__tests__/config_list.js +118 -0
  130. data/package/config_types/__tests__/config_object.js +43 -0
  131. data/package/config_types/config_list.js +75 -0
  132. data/package/config_types/config_object.js +55 -0
  133. data/package/config_types/index.js +7 -0
  134. data/package/dev_server.js +20 -0
  135. data/package/env.js +19 -0
  136. data/package/environments/__tests__/base.js +74 -0
  137. data/package/environments/base.js +166 -0
  138. data/package/environments/development.js +51 -0
  139. data/package/environments/production.js +79 -0
  140. data/package/environments/test.js +3 -0
  141. data/package/index.js +24 -0
  142. data/package/rules/babel.js +21 -0
  143. data/package/rules/css.js +3 -0
  144. data/package/rules/file.js +20 -0
  145. data/package/rules/index.js +20 -0
  146. data/package/rules/module.css.js +3 -0
  147. data/package/rules/module.sass.js +8 -0
  148. data/package/rules/node_modules.js +24 -0
  149. data/package/rules/sass.js +8 -0
  150. data/package/utils/__tests__/deep_assign.js +32 -0
  151. data/package/utils/__tests__/deep_merge.js +10 -0
  152. data/package/utils/__tests__/get_style_rule.js +65 -0
  153. data/package/utils/__tests__/objectify.js +9 -0
  154. data/package/utils/deep_assign.js +22 -0
  155. data/package/utils/deep_merge.js +22 -0
  156. data/package/utils/get_style_rule.js +45 -0
  157. data/package/utils/helpers.js +58 -0
  158. data/package/utils/objectify.js +3 -0
  159. data/test/command_test.rb +33 -0
  160. data/test/compiler_test.rb +75 -0
  161. data/test/configuration_test.rb +108 -0
  162. data/test/dev_server_runner_test.rb +51 -0
  163. data/test/dev_server_test.rb +47 -0
  164. data/test/env_test.rb +23 -0
  165. data/test/helper_test.rb +142 -0
  166. data/test/manifest_test.rb +42 -0
  167. data/test/rake_tasks_test.rb +69 -0
  168. data/test/test_app/Rakefile +3 -0
  169. data/test/test_app/app/javascript/packs/application.js +10 -0
  170. data/test/test_app/bin/webpack +14 -0
  171. data/test/test_app/bin/webpack-dev-server +14 -0
  172. data/test/test_app/config.ru +5 -0
  173. data/test/test_app/config/application.rb +12 -0
  174. data/test/test_app/config/environment.rb +4 -0
  175. data/test/test_app/config/webpack/development.js +0 -0
  176. data/test/test_app/config/webpacker.yml +97 -0
  177. data/test/test_app/config/webpacker_public_root.yml +19 -0
  178. data/test/test_app/package.json +13 -0
  179. data/test/test_app/public/packs/manifest.json +31 -0
  180. data/test/test_app/yarn.lock +11 -0
  181. data/test/test_helper.rb +33 -0
  182. data/test/webpack_runner_test.rb +51 -0
  183. data/test/webpacker_test.rb +13 -0
  184. data/yarn.lock +8321 -0
  185. metadata +267 -29
  186. data/.rspec +0 -3
  187. data/LICENSE.txt +0 -21
  188. data/bin/console +0 -14
  189. data/bin/setup +0 -8
  190. data/lib/jetpacker.rb +0 -6
@@ -1,28 +1,34 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
1
+ $:.push File.expand_path("../lib", __FILE__)
4
2
  require "jetpacker/version"
5
3
 
6
- Gem::Specification.new do |spec|
7
- spec.name = "jetpacker"
8
- spec.version = Jetpacker::VERSION
9
- spec.authors = ["Tung Nguyen"]
10
- spec.email = ["tongueroo@gmail.com"]
4
+ Gem::Specification.new do |s|
5
+ s.name = "jetpacker"
6
+ s.version = Jetpacker::VERSION
7
+ s.authors = [ "Tung Nguyen" ]
8
+ s.email = [ "tongueroo@gmail.com" ]
9
+ # Only commented out, so people do not accidentally contact incorrect person for jetspacker specific related issues.
10
+ # Credit goes to original authors of the work:
11
+ # s.authors = [ "David Heinemeier Hansson", "Gaurav Tiwari" ]
12
+ # s.email = [ "david@basecamp.com", "gaurav@gauravtiwari.co.uk" ]
13
+ s.summary = "Use webpack to manage app-like JavaScript modules in Jets"
14
+ s.homepage = "https://github.com/tonguero/jetpacker"
15
+ s.license = "MIT"
16
+
17
+ s.metadata = {
18
+ "source_code_uri" => "https://github.com/tongueroo/jetpacker/tree/v#{Jetpacker::VERSION}",
19
+ "changelog_uri" => "https://github.com/tongueroo/jetpacker/blob/v#{Jetpacker::VERSION}/CHANGELOG.md"
20
+ }
21
+
22
+ s.required_ruby_version = ">= 2.2.0"
11
23
 
12
- spec.summary = %q{Jetpacker}
13
- spec.homepage = "https://github.com/tongueroo/jetpacker"
14
- spec.license = "MIT"
24
+ s.add_dependency "activesupport", ">= 4.2"
25
+ s.add_dependency "railties", ">= 4.2"
26
+ s.add_dependency "rack-proxy", ">= 0.6.1"
15
27
 
16
- # Specify which files should be added to the gem when it is released.
17
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
- end
21
- spec.bindir = "exe"
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ["lib"]
28
+ s.add_development_dependency "bundler", ">= 1.3.0"
29
+ s.add_development_dependency "rubocop", "< 0.69"
30
+ s.add_development_dependency "rubocop-performance"
24
31
 
25
- spec.add_development_dependency "bundler", "~> 1.17"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
32
+ s.files = `git ls-files`.split("\n")
33
+ s.test_files = `git ls-files -- test/*`.split("\n")
28
34
  end
@@ -0,0 +1,23 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying angular example entry file to #{Webpacker.config.source_entry_path}"
4
+ copy_file "#{__dir__}/examples/angular/hello_angular.js", "#{Webpacker.config.source_entry_path}/hello_angular.js"
5
+
6
+ say "Copying hello_angular app to #{Webpacker.config.source_path}"
7
+ directory "#{__dir__}/examples/angular/hello_angular", "#{Webpacker.config.source_path}/hello_angular"
8
+
9
+ say "Installing all angular dependencies"
10
+ run "yarn add core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic"
11
+
12
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
13
+ say "You need to enable unsafe-eval rule.", :yellow
14
+ say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
15
+ say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
16
+ say "if Jets.env.development?", :yellow
17
+ say " policy.script_src :self, :https, :unsafe_eval", :yellow
18
+ say "else", :yellow
19
+ say " policy.script_src :self, :https", :yellow
20
+ say "end", :yellow
21
+ end
22
+
23
+ say "Webpacker now supports angular 🎉", :green
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["JETS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/webpack_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::WebpackRunner.run(ARGV)
18
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["JETS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/dev_server_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::DevServerRunner.run(ARGV)
18
+ end
@@ -0,0 +1,4 @@
1
+ say "Copying binstubs"
2
+ directory "#{__dir__}/bin", "bin"
3
+
4
+ chmod "bin", 0755 & ~File.umask, verbose: false
@@ -0,0 +1,25 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying coffee loader to config/webpack/loaders"
4
+ copy_file "#{__dir__}/loaders/coffee.js", Jets.root.join("config/webpack/loaders/coffee.js").to_s
5
+
6
+ say "Adding coffee loader to config/webpack/environment.js"
7
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
8
+ "const coffee = require('./loaders/coffee')\n",
9
+ after: /require\(('|")@rails\/webpacker\1\);?\n/
10
+
11
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
12
+ "environment.loaders.prepend('coffee', coffee)\n",
13
+ before: "module.exports"
14
+
15
+ say "Updating webpack paths to include .coffee file extension"
16
+ insert_into_file Webpacker.config.config_path, "- .coffee\n".indent(4), after: /\s+extensions:\n/
17
+
18
+ say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
19
+ copy_file "#{__dir__}/examples/coffee/hello_coffee.coffee",
20
+ "#{Webpacker.config.source_entry_path}/hello_coffee.coffee"
21
+
22
+ say "Installing all Coffeescript dependencies"
23
+ run "yarn add coffeescript@1.12.7 coffee-loader"
24
+
25
+ say "Webpacker now supports Coffeescript 🎉", :green
@@ -0,0 +1 @@
1
+ defaults
@@ -0,0 +1,72 @@
1
+ module.exports = function(api) {
2
+ var validEnv = ['development', 'test', 'production']
3
+ var currentEnv = api.env()
4
+ var isDevelopmentEnv = api.env('development')
5
+ var isProductionEnv = api.env('production')
6
+ var isTestEnv = api.env('test')
7
+
8
+ if (!validEnv.includes(currentEnv)) {
9
+ throw new Error(
10
+ 'Please specify a valid `NODE_ENV` or ' +
11
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
+ '"test", and "production". Instead, received: ' +
13
+ JSON.stringify(currentEnv) +
14
+ '.'
15
+ )
16
+ }
17
+
18
+ return {
19
+ presets: [
20
+ isTestEnv && [
21
+ '@babel/preset-env',
22
+ {
23
+ targets: {
24
+ node: 'current'
25
+ }
26
+ }
27
+ ],
28
+ (isProductionEnv || isDevelopmentEnv) && [
29
+ '@babel/preset-env',
30
+ {
31
+ forceAllTransforms: true,
32
+ useBuiltIns: 'entry',
33
+ corejs: 3,
34
+ modules: false,
35
+ exclude: ['transform-typeof-symbol']
36
+ }
37
+ ]
38
+ ].filter(Boolean),
39
+ plugins: [
40
+ 'babel-plugin-macros',
41
+ '@babel/plugin-syntax-dynamic-import',
42
+ isTestEnv && 'babel-plugin-dynamic-import-node',
43
+ '@babel/plugin-transform-destructuring',
44
+ [
45
+ '@babel/plugin-proposal-class-properties',
46
+ {
47
+ loose: true
48
+ }
49
+ ],
50
+ [
51
+ '@babel/plugin-proposal-object-rest-spread',
52
+ {
53
+ useBuiltIns: true
54
+ }
55
+ ],
56
+ [
57
+ '@babel/plugin-transform-runtime',
58
+ {
59
+ helpers: false,
60
+ regenerator: true,
61
+ corejs: false
62
+ }
63
+ ],
64
+ [
65
+ '@babel/plugin-transform-regenerator',
66
+ {
67
+ async: false
68
+ }
69
+ ]
70
+ ].filter(Boolean)
71
+ }
72
+ }
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ plugins: [
3
+ require('postcss-import'),
4
+ require('postcss-flexbugs-fixes'),
5
+ require('postcss-preset-env')({
6
+ autoprefixer: {
7
+ flexbox: 'no-2009'
8
+ },
9
+ stage: 3
10
+ })
11
+ ]
12
+ }
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,3 @@
1
+ const { environment } = require('@rails/webpacker')
2
+
3
+ module.exports = environment
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,96 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_root_path: public
7
+ public_output_path: packs
8
+ cache_path: tmp/cache/webpacker
9
+ check_yarn_integrity: false
10
+ webpack_compile_output: true
11
+
12
+ # Additional paths webpack should lookup modules
13
+ # ['app/assets', 'engine/foo/app/assets']
14
+ resolved_paths: []
15
+
16
+ # Reload manifest.json on all requests so we reload latest compiled packs
17
+ cache_manifest: false
18
+
19
+ # Extract and emit a css file
20
+ extract_css: false
21
+
22
+ static_assets_extensions:
23
+ - .jpg
24
+ - .jpeg
25
+ - .png
26
+ - .gif
27
+ - .tiff
28
+ - .ico
29
+ - .svg
30
+ - .eot
31
+ - .otf
32
+ - .ttf
33
+ - .woff
34
+ - .woff2
35
+
36
+ extensions:
37
+ - .mjs
38
+ - .js
39
+ - .sass
40
+ - .scss
41
+ - .css
42
+ - .module.sass
43
+ - .module.scss
44
+ - .module.css
45
+ - .png
46
+ - .svg
47
+ - .gif
48
+ - .jpeg
49
+ - .jpg
50
+
51
+ development:
52
+ <<: *default
53
+ compile: true
54
+
55
+ # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
56
+ check_yarn_integrity: true
57
+
58
+ # Reference: https://webpack.js.org/configuration/dev-server/
59
+ dev_server:
60
+ https: false
61
+ host: localhost
62
+ port: 3035
63
+ public: localhost:3035
64
+ hmr: false
65
+ # Inline should be set to true if using HMR
66
+ inline: true
67
+ overlay: true
68
+ compress: true
69
+ disable_host_check: true
70
+ use_local_ip: false
71
+ quiet: false
72
+ pretty: false
73
+ headers:
74
+ 'Access-Control-Allow-Origin': '*'
75
+ watch_options:
76
+ ignored: '**/node_modules/**'
77
+
78
+
79
+ test:
80
+ <<: *default
81
+ compile: true
82
+
83
+ # Compile test packs to a separate directory
84
+ public_output_path: packs-test
85
+
86
+ production:
87
+ <<: *default
88
+
89
+ # Production depends on precompilation of packs prior to booting for performance.
90
+ compile: false
91
+
92
+ # Extract and emit a css file
93
+ extract_css: true
94
+
95
+ # Cache manifest.json for performance
96
+ cache_manifest: true
@@ -0,0 +1,39 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying elm loader to config/webpack/loaders"
4
+ copy_file "#{__dir__}/loaders/elm.js", Jets.root.join("config/webpack/loaders/elm.js").to_s
5
+
6
+ say "Adding elm loader to config/webpack/environment.js"
7
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
8
+ "const elm = require('./loaders/elm')\n",
9
+ after: /require\(('|")@rails\/webpacker\1\);?\n/
10
+
11
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
12
+ "environment.loaders.prepend('elm', elm)\n",
13
+ before: "module.exports"
14
+
15
+ say "Copying Elm example entry file to #{Webpacker.config.source_entry_path}"
16
+ copy_file "#{__dir__}/examples/elm/hello_elm.js",
17
+ "#{Webpacker.config.source_entry_path}/hello_elm.js"
18
+
19
+ say "Copying Elm app file to #{Webpacker.config.source_path}"
20
+ copy_file "#{__dir__}/examples/elm/Main.elm",
21
+ "#{Webpacker.config.source_path}/Main.elm"
22
+
23
+ say "Installing all Elm dependencies"
24
+ run "yarn add elm elm-webpack-loader"
25
+ run "yarn add --dev elm-hot-webpack-loader"
26
+ run "yarn run elm init"
27
+ run "yarn run elm make #{Webpacker.config.source_path}/Main.elm"
28
+
29
+ say "Updating webpack paths to include .elm file extension"
30
+ insert_into_file Webpacker.config.config_path, "- .elm\n".indent(4), after: /\s+extensions:\n/
31
+
32
+ say "Updating Elm source location"
33
+ gsub_file "elm.json", /\"src\"\n/,
34
+ %("#{Webpacker.config.source_path.relative_path_from(Jets.root)}"\n)
35
+
36
+ say "Updating .gitignore to include elm-stuff folder"
37
+ insert_into_file ".gitignore", "/elm-stuff\n", before: "/node_modules\n"
38
+
39
+ say "Webpacker now supports Elm 🎉", :green
@@ -0,0 +1,25 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying erb loader to config/webpack/loaders"
4
+ copy_file "#{__dir__}/loaders/erb.js", Jets.root.join("config/webpack/loaders/erb.js").to_s
5
+
6
+ say "Adding erb loader to config/webpack/environment.js"
7
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
8
+ "const erb = require('./loaders/erb')\n",
9
+ after: /require\(('|")@rails\/webpacker\1\);?\n/
10
+
11
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
12
+ "environment.loaders.prepend('erb', erb)\n",
13
+ before: "module.exports"
14
+
15
+ say "Updating webpack paths to include .erb file extension"
16
+ insert_into_file Webpacker.config.config_path, "- .erb\n".indent(4), after: /\s+extensions:\n/
17
+
18
+ say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
19
+ copy_file "#{__dir__}/examples/erb/hello_erb.js.erb",
20
+ "#{Webpacker.config.source_entry_path}/hello_erb.js.erb"
21
+
22
+ say "Installing all Erb dependencies"
23
+ run "yarn add rails-erb-loader"
24
+
25
+ say "Webpacker now supports Erb in JS 🎉", :green
@@ -0,0 +1,7 @@
1
+ // Run this Angular example by adding the following HTML markup to your view:
2
+ //
3
+ // <hello-angular>Loading...</hello-angular>
4
+ //
5
+ // <%= javascript_pack_tag 'hello_angular' %>
6
+
7
+ require('../hello_angular')
@@ -0,0 +1,9 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'hello-angular',
5
+ template: `<h1>Hello {{name}}</h1>`
6
+ })
7
+ export class AppComponent {
8
+ name = 'Angular!';
9
+ }