tiny-lite-sys 0.0.1

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 (177) hide show
  1. checksums.yaml +7 -0
  2. data/tiny-lite-sys.gemspec +11 -0
  3. data/webpacker-5.4.4/CHANGELOG.md +1074 -0
  4. data/webpacker-5.4.4/CONTRIBUTING.md +33 -0
  5. data/webpacker-5.4.4/Gemfile +13 -0
  6. data/webpacker-5.4.4/Gemfile.lock +183 -0
  7. data/webpacker-5.4.4/MIT-LICENSE +20 -0
  8. data/webpacker-5.4.4/README.md +427 -0
  9. data/webpacker-5.4.4/Rakefile +11 -0
  10. data/webpacker-5.4.4/docs/assets.md +119 -0
  11. data/webpacker-5.4.4/docs/cloud9.md +310 -0
  12. data/webpacker-5.4.4/docs/css.md +308 -0
  13. data/webpacker-5.4.4/docs/deployment.md +130 -0
  14. data/webpacker-5.4.4/docs/docker.md +68 -0
  15. data/webpacker-5.4.4/docs/engines.md +213 -0
  16. data/webpacker-5.4.4/docs/env.md +63 -0
  17. data/webpacker-5.4.4/docs/es6.md +72 -0
  18. data/webpacker-5.4.4/docs/folder-structure.md +66 -0
  19. data/webpacker-5.4.4/docs/integrations.md +220 -0
  20. data/webpacker-5.4.4/docs/misc.md +23 -0
  21. data/webpacker-5.4.4/docs/props.md +223 -0
  22. data/webpacker-5.4.4/docs/target.md +22 -0
  23. data/webpacker-5.4.4/docs/testing.md +136 -0
  24. data/webpacker-5.4.4/docs/troubleshooting.md +158 -0
  25. data/webpacker-5.4.4/docs/typescript.md +190 -0
  26. data/webpacker-5.4.4/docs/v4-upgrade.md +142 -0
  27. data/webpacker-5.4.4/docs/webpack-dev-server.md +92 -0
  28. data/webpacker-5.4.4/docs/webpack.md +364 -0
  29. data/webpacker-5.4.4/docs/yarn.md +23 -0
  30. data/webpacker-5.4.4/gemfiles/Gemfile-rails-edge +12 -0
  31. data/webpacker-5.4.4/gemfiles/Gemfile-rails.5.2.x +9 -0
  32. data/webpacker-5.4.4/gemfiles/Gemfile-rails.6.0.x +9 -0
  33. data/webpacker-5.4.4/lib/install/angular.rb +23 -0
  34. data/webpacker-5.4.4/lib/install/bin/webpack +18 -0
  35. data/webpacker-5.4.4/lib/install/bin/webpack-dev-server +18 -0
  36. data/webpacker-5.4.4/lib/install/binstubs.rb +4 -0
  37. data/webpacker-5.4.4/lib/install/coffee.rb +25 -0
  38. data/webpacker-5.4.4/lib/install/config/babel.config.js +82 -0
  39. data/webpacker-5.4.4/lib/install/config/postcss.config.js +12 -0
  40. data/webpacker-5.4.4/lib/install/config/webpack/development.js +5 -0
  41. data/webpacker-5.4.4/lib/install/config/webpack/environment.js +3 -0
  42. data/webpacker-5.4.4/lib/install/config/webpack/production.js +5 -0
  43. data/webpacker-5.4.4/lib/install/config/webpack/test.js +5 -0
  44. data/webpacker-5.4.4/lib/install/config/webpacker.yml +92 -0
  45. data/webpacker-5.4.4/lib/install/elm.rb +39 -0
  46. data/webpacker-5.4.4/lib/install/erb.rb +25 -0
  47. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
  48. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
  49. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/index.ts +8 -0
  50. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/polyfills.ts +73 -0
  51. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular.js +7 -0
  52. data/webpacker-5.4.4/lib/install/examples/coffee/hello_coffee.coffee +4 -0
  53. data/webpacker-5.4.4/lib/install/examples/elm/Main.elm +55 -0
  54. data/webpacker-5.4.4/lib/install/examples/elm/hello_elm.js +16 -0
  55. data/webpacker-5.4.4/lib/install/examples/erb/hello_erb.js.erb +6 -0
  56. data/webpacker-5.4.4/lib/install/examples/react/babel.config.js +99 -0
  57. data/webpacker-5.4.4/lib/install/examples/react/hello_react.jsx +26 -0
  58. data/webpacker-5.4.4/lib/install/examples/react/tsconfig.json +21 -0
  59. data/webpacker-5.4.4/lib/install/examples/stimulus/application.js +1 -0
  60. data/webpacker-5.4.4/lib/install/examples/stimulus/controllers/hello_controller.js +18 -0
  61. data/webpacker-5.4.4/lib/install/examples/stimulus/controllers/index.js +9 -0
  62. data/webpacker-5.4.4/lib/install/examples/svelte/app.svelte +11 -0
  63. data/webpacker-5.4.4/lib/install/examples/svelte/hello_svelte.js +20 -0
  64. data/webpacker-5.4.4/lib/install/examples/typescript/hello_typescript.ts +4 -0
  65. data/webpacker-5.4.4/lib/install/examples/typescript/tsconfig.json +24 -0
  66. data/webpacker-5.4.4/lib/install/examples/vue/app.vue +22 -0
  67. data/webpacker-5.4.4/lib/install/examples/vue/hello_vue.js +72 -0
  68. data/webpacker-5.4.4/lib/install/javascript/packs/application.js +18 -0
  69. data/webpacker-5.4.4/lib/install/loaders/coffee.js +6 -0
  70. data/webpacker-5.4.4/lib/install/loaders/elm.js +25 -0
  71. data/webpacker-5.4.4/lib/install/loaders/erb.js +11 -0
  72. data/webpacker-5.4.4/lib/install/loaders/svelte.js +9 -0
  73. data/webpacker-5.4.4/lib/install/loaders/vue.js +6 -0
  74. data/webpacker-5.4.4/lib/install/react.rb +18 -0
  75. data/webpacker-5.4.4/lib/install/stimulus.rb +12 -0
  76. data/webpacker-5.4.4/lib/install/svelte.rb +29 -0
  77. data/webpacker-5.4.4/lib/install/template.rb +63 -0
  78. data/webpacker-5.4.4/lib/install/typescript.rb +39 -0
  79. data/webpacker-5.4.4/lib/install/vue.rb +49 -0
  80. data/webpacker-5.4.4/lib/tasks/installers.rake +42 -0
  81. data/webpacker-5.4.4/lib/tasks/webpacker/binstubs.rake +13 -0
  82. data/webpacker-5.4.4/lib/tasks/webpacker/check_binstubs.rake +12 -0
  83. data/webpacker-5.4.4/lib/tasks/webpacker/check_node.rake +31 -0
  84. data/webpacker-5.4.4/lib/tasks/webpacker/check_yarn.rake +30 -0
  85. data/webpacker-5.4.4/lib/tasks/webpacker/clean.rake +25 -0
  86. data/webpacker-5.4.4/lib/tasks/webpacker/clobber.rake +20 -0
  87. data/webpacker-5.4.4/lib/tasks/webpacker/compile.rake +43 -0
  88. data/webpacker-5.4.4/lib/tasks/webpacker/info.rake +19 -0
  89. data/webpacker-5.4.4/lib/tasks/webpacker/install.rake +13 -0
  90. data/webpacker-5.4.4/lib/tasks/webpacker/verify_install.rake +13 -0
  91. data/webpacker-5.4.4/lib/tasks/webpacker/yarn_install.rake +16 -0
  92. data/webpacker-5.4.4/lib/tasks/webpacker.rake +28 -0
  93. data/webpacker-5.4.4/lib/webpacker/commands.rb +74 -0
  94. data/webpacker-5.4.4/lib/webpacker/compiler.rb +111 -0
  95. data/webpacker-5.4.4/lib/webpacker/configuration.rb +128 -0
  96. data/webpacker-5.4.4/lib/webpacker/dev_server.rb +66 -0
  97. data/webpacker-5.4.4/lib/webpacker/dev_server_proxy.rb +33 -0
  98. data/webpacker-5.4.4/lib/webpacker/dev_server_runner.rb +72 -0
  99. data/webpacker-5.4.4/lib/webpacker/env.rb +43 -0
  100. data/webpacker-5.4.4/lib/webpacker/helper.rb +195 -0
  101. data/webpacker-5.4.4/lib/webpacker/instance.rb +37 -0
  102. data/webpacker-5.4.4/lib/webpacker/manifest.rb +118 -0
  103. data/webpacker-5.4.4/lib/webpacker/railtie.rb +55 -0
  104. data/webpacker-5.4.4/lib/webpacker/runner.rb +23 -0
  105. data/webpacker-5.4.4/lib/webpacker/version.rb +4 -0
  106. data/webpacker-5.4.4/lib/webpacker/webpack_runner.rb +32 -0
  107. data/webpacker-5.4.4/lib/webpacker.rb +46 -0
  108. data/webpacker-5.4.4/package/__tests__/config.js +66 -0
  109. data/webpacker-5.4.4/package/__tests__/dev_server.js +45 -0
  110. data/webpacker-5.4.4/package/__tests__/development.js +43 -0
  111. data/webpacker-5.4.4/package/__tests__/env.js +46 -0
  112. data/webpacker-5.4.4/package/__tests__/production.js +29 -0
  113. data/webpacker-5.4.4/package/__tests__/staging.js +29 -0
  114. data/webpacker-5.4.4/package/__tests__/test.js +26 -0
  115. data/webpacker-5.4.4/package/config.js +40 -0
  116. data/webpacker-5.4.4/package/configPath.js +3 -0
  117. data/webpacker-5.4.4/package/config_types/__tests__/config_list.js +118 -0
  118. data/webpacker-5.4.4/package/config_types/__tests__/config_object.js +43 -0
  119. data/webpacker-5.4.4/package/config_types/config_list.js +75 -0
  120. data/webpacker-5.4.4/package/config_types/config_object.js +55 -0
  121. data/webpacker-5.4.4/package/config_types/index.js +7 -0
  122. data/webpacker-5.4.4/package/dev_server.js +20 -0
  123. data/webpacker-5.4.4/package/env.js +18 -0
  124. data/webpacker-5.4.4/package/environments/__tests__/base.js +101 -0
  125. data/webpacker-5.4.4/package/environments/base.js +176 -0
  126. data/webpacker-5.4.4/package/environments/development.js +53 -0
  127. data/webpacker-5.4.4/package/environments/production.js +77 -0
  128. data/webpacker-5.4.4/package/environments/test.js +3 -0
  129. data/webpacker-5.4.4/package/index.js +24 -0
  130. data/webpacker-5.4.4/package/rules/babel.js +28 -0
  131. data/webpacker-5.4.4/package/rules/css.js +3 -0
  132. data/webpacker-5.4.4/package/rules/file.js +21 -0
  133. data/webpacker-5.4.4/package/rules/index.js +20 -0
  134. data/webpacker-5.4.4/package/rules/module.css.js +3 -0
  135. data/webpacker-5.4.4/package/rules/module.sass.js +8 -0
  136. data/webpacker-5.4.4/package/rules/node_modules.js +22 -0
  137. data/webpacker-5.4.4/package/rules/sass.js +17 -0
  138. data/webpacker-5.4.4/package/utils/__tests__/deep_assign.js +32 -0
  139. data/webpacker-5.4.4/package/utils/__tests__/deep_merge.js +10 -0
  140. data/webpacker-5.4.4/package/utils/__tests__/get_style_rule.js +65 -0
  141. data/webpacker-5.4.4/package/utils/__tests__/objectify.js +9 -0
  142. data/webpacker-5.4.4/package/utils/deep_assign.js +22 -0
  143. data/webpacker-5.4.4/package/utils/deep_merge.js +22 -0
  144. data/webpacker-5.4.4/package/utils/get_style_rule.js +45 -0
  145. data/webpacker-5.4.4/package/utils/helpers.js +58 -0
  146. data/webpacker-5.4.4/package/utils/objectify.js +3 -0
  147. data/webpacker-5.4.4/package.json +82 -0
  148. data/webpacker-5.4.4/test/command_test.rb +33 -0
  149. data/webpacker-5.4.4/test/compiler_test.rb +80 -0
  150. data/webpacker-5.4.4/test/configuration_test.rb +109 -0
  151. data/webpacker-5.4.4/test/dev_server_runner_test.rb +51 -0
  152. data/webpacker-5.4.4/test/dev_server_test.rb +47 -0
  153. data/webpacker-5.4.4/test/env_test.rb +23 -0
  154. data/webpacker-5.4.4/test/helper_test.rb +157 -0
  155. data/webpacker-5.4.4/test/manifest_test.rb +73 -0
  156. data/webpacker-5.4.4/test/rake_tasks_test.rb +80 -0
  157. data/webpacker-5.4.4/test/test_app/Rakefile +3 -0
  158. data/webpacker-5.4.4/test/test_app/app/javascript/packs/application.js +10 -0
  159. data/webpacker-5.4.4/test/test_app/app/javascript/packs/multi_entry.css +4 -0
  160. data/webpacker-5.4.4/test/test_app/app/javascript/packs/multi_entry.js +4 -0
  161. data/webpacker-5.4.4/test/test_app/bin/webpack +14 -0
  162. data/webpacker-5.4.4/test/test_app/bin/webpack-dev-server +14 -0
  163. data/webpacker-5.4.4/test/test_app/config/application.rb +11 -0
  164. data/webpacker-5.4.4/test/test_app/config/environment.rb +4 -0
  165. data/webpacker-5.4.4/test/test_app/config/webpack/development.js +0 -0
  166. data/webpacker-5.4.4/test/test_app/config/webpacker.yml +103 -0
  167. data/webpacker-5.4.4/test/test_app/config/webpacker_public_root.yml +19 -0
  168. data/webpacker-5.4.4/test/test_app/config.ru +5 -0
  169. data/webpacker-5.4.4/test/test_app/package.json +13 -0
  170. data/webpacker-5.4.4/test/test_app/public/packs/manifest.json +32 -0
  171. data/webpacker-5.4.4/test/test_app/yarn.lock +11 -0
  172. data/webpacker-5.4.4/test/test_helper.rb +33 -0
  173. data/webpacker-5.4.4/test/webpack_runner_test.rb +51 -0
  174. data/webpacker-5.4.4/test/webpacker_test.rb +13 -0
  175. data/webpacker-5.4.4/webpacker.gemspec +31 -0
  176. data/webpacker-5.4.4/yarn.lock +8271 -0
  177. metadata +215 -0
@@ -0,0 +1,72 @@
1
+ /* eslint no-console: 0 */
2
+ // Run this example by adding <%= javascript_pack_tag 'hello_vue' %> (and
3
+ // <%= stylesheet_pack_tag 'hello_vue' %> if you have styles in your component)
4
+ // to the head of your layout file,
5
+ // like app/views/layouts/application.html.erb.
6
+ // All it does is render <div>Hello Vue</div> at the bottom of the page.
7
+
8
+ import Vue from 'vue'
9
+ import App from '../app.vue'
10
+
11
+ document.addEventListener('DOMContentLoaded', () => {
12
+ const app = new Vue({
13
+ render: h => h(App)
14
+ }).$mount()
15
+ document.body.appendChild(app.$el)
16
+
17
+ console.log(app)
18
+ })
19
+
20
+
21
+ // The above code uses Vue without the compiler, which means you cannot
22
+ // use Vue to target elements in your existing html templates. You would
23
+ // need to always use single file components.
24
+ // To be able to target elements in your existing html/erb templates,
25
+ // comment out the above code and uncomment the below
26
+ // Add <%= javascript_pack_tag 'hello_vue' %> to your layout
27
+ // Then add this markup to your html template:
28
+ //
29
+ // <div id='hello'>
30
+ // {{message}}
31
+ // <app></app>
32
+ // </div>
33
+
34
+
35
+ // import Vue from 'vue/dist/vue.esm'
36
+ // import App from '../app.vue'
37
+ //
38
+ // document.addEventListener('DOMContentLoaded', () => {
39
+ // const app = new Vue({
40
+ // el: '#hello',
41
+ // data: {
42
+ // message: "Can you say hello?"
43
+ // },
44
+ // components: { App }
45
+ // })
46
+ // })
47
+ //
48
+ //
49
+ //
50
+ // If the project is using turbolinks, install 'vue-turbolinks':
51
+ //
52
+ // yarn add vue-turbolinks
53
+ //
54
+ // Then uncomment the code block below:
55
+ //
56
+ // import TurbolinksAdapter from 'vue-turbolinks'
57
+ // import Vue from 'vue/dist/vue.esm'
58
+ // import App from '../app.vue'
59
+ //
60
+ // Vue.use(TurbolinksAdapter)
61
+ //
62
+ // document.addEventListener('turbolinks:load', () => {
63
+ // const app = new Vue({
64
+ // el: '#hello',
65
+ // data: () => {
66
+ // return {
67
+ // message: "Can you say hello?"
68
+ // }
69
+ // },
70
+ // components: { App }
71
+ // })
72
+ // })
@@ -0,0 +1,18 @@
1
+ /* eslint no-console:0 */
2
+ // This file is automatically compiled by Webpack, along with any other files
3
+ // present in this directory. You're encouraged to place your actual application logic in
4
+ // a relevant structure within app/javascript and only use these pack files to reference
5
+ // that code so it'll be compiled.
6
+ //
7
+ // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8
+ // layout file, like app/views/layouts/application.html.erb
9
+
10
+
11
+ // Uncomment to copy all static images under ../images to the output folder and reference
12
+ // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
13
+ // or the `imagePath` JavaScript helper below.
14
+ //
15
+ // const images = require.context('../images', true)
16
+ // const imagePath = (name) => images(name, true)
17
+
18
+ console.log('Hello World from Webpacker')
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ test: /\.coffee(\.erb)?$/,
3
+ use: [{
4
+ loader: 'coffee-loader'
5
+ }]
6
+ }
@@ -0,0 +1,25 @@
1
+ const { resolve } = require('path')
2
+
3
+ const isProduction = process.env.NODE_ENV === 'production'
4
+ const isDevelopment = process.env.NODE_ENV === 'development'
5
+ const elmSource = resolve(process.cwd())
6
+ const elmBinary = `${elmSource}/node_modules/.bin/elm`
7
+
8
+ const options = {
9
+ cwd: elmSource,
10
+ pathToElm: elmBinary,
11
+ optimize: isProduction,
12
+ verbose: isDevelopment,
13
+ debug: isDevelopment
14
+ }
15
+
16
+ const elmWebpackLoader = {
17
+ loader: 'elm-webpack-loader',
18
+ options: options
19
+ }
20
+
21
+ module.exports = {
22
+ test: /\.elm(\.erb)?$/,
23
+ exclude: [/elm-stuff/, /node_modules/],
24
+ use: isProduction ? [elmWebpackLoader] : [{ loader: 'elm-hot-webpack-loader' }, elmWebpackLoader]
25
+ }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ test: /\.erb$/,
3
+ enforce: 'pre',
4
+ exclude: /node_modules/,
5
+ use: [{
6
+ loader: 'rails-erb-loader',
7
+ options: {
8
+ runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner'
9
+ }
10
+ }]
11
+ }
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ test: /\.svelte(\.erb)?$/,
3
+ use: [{
4
+ loader: 'svelte-loader',
5
+ options: {
6
+ hotReload: false
7
+ }
8
+ }],
9
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ test: /\.vue(\.erb)?$/,
3
+ use: [{
4
+ loader: 'vue-loader'
5
+ }]
6
+ }
@@ -0,0 +1,18 @@
1
+ require "webpacker/configuration"
2
+ require "fileutils"
3
+
4
+ replace_babel_config = FileUtils.compare_file(Rails.root.join("babel.config.js"), "#{__dir__}/config/babel.config.js")
5
+
6
+ say "Copying babel.config.js to app root directory"
7
+ copy_file "#{__dir__}/examples/react/babel.config.js", "babel.config.js", force: replace_babel_config
8
+
9
+ say "Copying react example entry file to #{Webpacker.config.source_entry_path}"
10
+ copy_file "#{__dir__}/examples/react/hello_react.jsx", "#{Webpacker.config.source_entry_path}/hello_react.jsx"
11
+
12
+ say "Updating webpack paths to include .jsx file extension"
13
+ insert_into_file Webpacker.config.config_path, "- .jsx\n".indent(4), after: /\s+extensions:\n/
14
+
15
+ say "Installing all react dependencies"
16
+ run "yarn add react react-dom @babel/preset-react prop-types babel-plugin-transform-react-remove-prop-types"
17
+
18
+ say "Webpacker now supports react.js 🎉", :green
@@ -0,0 +1,12 @@
1
+ say "Appending Stimulus setup code to #{Webpacker.config.source_entry_path}/application.js"
2
+ append_to_file "#{Webpacker.config.source_entry_path}/application.js" do
3
+ "\n" + open("#{__dir__}/examples/stimulus/application.js").read
4
+ end
5
+
6
+ say "Creating controllers directory"
7
+ directory "#{__dir__}/examples/stimulus/controllers", "#{Webpacker.config.source_path}/controllers"
8
+
9
+ say "Installing all Stimulus dependencies"
10
+ run "yarn add stimulus"
11
+
12
+ say "Webpacker now supports Stimulus.js 🎉", :green
@@ -0,0 +1,29 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying svelte loader to config/webpack/loaders"
4
+ copy_file "#{__dir__}/loaders/svelte.js", Rails.root.join("config/webpack/loaders/svelte.js").to_s
5
+
6
+ say "Adding svelte loader to config/webpack/environment.js"
7
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
8
+ "const svelte = require('./loaders/svelte')\n",
9
+ after: /require\(('|")@rails\/webpacker\1\);?\n/
10
+
11
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
12
+ "environment.loaders.prepend('svelte', svelte)\n",
13
+ before: "module.exports"
14
+
15
+ say "Copying Svelte example entry file to #{Webpacker.config.source_entry_path}"
16
+ copy_file "#{__dir__}/examples/svelte/hello_svelte.js",
17
+ "#{Webpacker.config.source_entry_path}/hello_svelte.js"
18
+
19
+ say "Copying Svelte app file to #{Webpacker.config.source_path}"
20
+ copy_file "#{__dir__}/examples/svelte/app.svelte",
21
+ "#{Webpacker.config.source_path}/app.svelte"
22
+
23
+ say "Installing all Svelte dependencies"
24
+ run "yarn add svelte svelte-loader"
25
+
26
+ say "Updating webpack paths to include .svelte file extension"
27
+ insert_into_file Webpacker.config.config_path, "- .svelte\n".indent(4), after: /\s+extensions:\n/
28
+
29
+ say "Webpacker now supports Svelte 🎉", :green
@@ -0,0 +1,63 @@
1
+ # Install Webpacker
2
+ copy_file "#{__dir__}/config/webpacker.yml", "config/webpacker.yml"
3
+
4
+ say "Copying webpack core config"
5
+ directory "#{__dir__}/config/webpack", "config/webpack"
6
+
7
+ say "Copying postcss.config.js to app root directory"
8
+ copy_file "#{__dir__}/config/postcss.config.js", "postcss.config.js"
9
+
10
+ say "Copying babel.config.js to app root directory"
11
+ copy_file "#{__dir__}/config/babel.config.js", "babel.config.js"
12
+
13
+ say "Copying .browserslistrc to app root directory"
14
+ copy_file "#{__dir__}/config/.browserslistrc", ".browserslistrc"
15
+
16
+ if Dir.exist?(Webpacker.config.source_path)
17
+ say "The JavaScript app source directory already exists"
18
+ else
19
+ say "Creating JavaScript app source directory"
20
+ directory "#{__dir__}/javascript", Webpacker.config.source_path
21
+ end
22
+
23
+ apply "#{__dir__}/binstubs.rb"
24
+
25
+ if File.exist?(".gitignore")
26
+ append_to_file ".gitignore" do
27
+ "\n" +
28
+ "/public/packs\n" +
29
+ "/public/packs-test\n" +
30
+ "/node_modules\n" +
31
+ "/yarn-error.log\n" +
32
+ "yarn-debug.log*\n" +
33
+ ".yarn-integrity\n"
34
+ end
35
+ end
36
+
37
+ if Webpacker::VERSION.match?(/^[0-9]+\.[0-9]+\.[0-9]+$/)
38
+ say "Installing all JavaScript dependencies [#{Webpacker::VERSION}]"
39
+ run "yarn add @rails/webpacker@#{Webpacker::VERSION}"
40
+ else
41
+ say "Installing all JavaScript dependencies [from prerelease rails/webpacker]"
42
+ run "yarn add @rails/webpacker@next"
43
+ end
44
+
45
+ package_json = File.read("#{__dir__}/../../package.json")
46
+ webpack_version = package_json.match(/"webpack": "(.*)"/)[1]
47
+ webpack_cli_version = package_json.match(/"webpack-cli": "(.*)"/)[1]
48
+
49
+ # needed for experimental Yarn 2 support and should not harm Yarn 1
50
+ say "Installing webpack and webpack-cli as direct dependencies"
51
+ run "yarn add webpack@#{webpack_version} webpack-cli@#{webpack_cli_version}"
52
+
53
+ say "Installing dev server for live reloading"
54
+ run "yarn add --dev webpack-dev-server@^3"
55
+
56
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
57
+ say "You need to allow webpack-dev-server host as allowed origin for connect-src.", :yellow
58
+ say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
59
+ say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
60
+ say "policy.connect_src :self, :https, \"http://localhost:3035\", \"ws://localhost:3035\" if Rails.env.development?", :yellow
61
+ end
62
+
63
+ say "Webpacker successfully installed 🎉 🍰", :green
@@ -0,0 +1,39 @@
1
+ require "webpacker/configuration"
2
+
3
+ additional_packages = ""
4
+ example_source = "typescript"
5
+
6
+ # Additional configuration is required for React projects
7
+ package_json = Rails.root.join("package.json")
8
+ if File.exist?(package_json)
9
+ package = JSON.parse(File.read(package_json))
10
+ package["dependencies"] ||= {}
11
+
12
+ if package["dependencies"].key?("react")
13
+ additional_packages = "@types/react @types/react-dom"
14
+ example_source = "react"
15
+ end
16
+ end
17
+
18
+ say "Adding TypeScript preset to babel.config.js"
19
+ insert_into_file Rails.root.join("babel.config.js").to_s,
20
+ ",\n ['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]",
21
+ before: /\s*\].filter\(Boolean\),\n\s*plugins: \[/
22
+
23
+ say "Copying tsconfig.json to the Rails root directory for typescript"
24
+ copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json"
25
+
26
+ say "Updating webpack paths to include .ts file extension"
27
+ insert_into_file Webpacker.config.config_path, "- .ts\n".indent(4), after: /\s+extensions:\n/
28
+
29
+ say "Updating webpack paths to include .tsx file extension"
30
+ insert_into_file Webpacker.config.config_path, "- .tsx\n".indent(4), after: /\s+extensions:\n/
31
+
32
+ say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
33
+ copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
34
+ "#{Webpacker.config.source_entry_path}/hello_typescript.ts"
35
+
36
+ say "Installing all typescript dependencies"
37
+ run "yarn add typescript @babel/preset-typescript #{additional_packages}"
38
+
39
+ say "Webpacker now supports typescript 🎉", :green
@@ -0,0 +1,49 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying vue loader to config/webpack/loaders"
4
+ copy_file "#{__dir__}/loaders/vue.js", Rails.root.join("config/webpack/loaders/vue.js").to_s
5
+
6
+ say "Adding vue loader plugin to config/webpack/environment.js"
7
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
8
+ "const { VueLoaderPlugin } = require('vue-loader')\n",
9
+ after: /require\(('|")@rails\/webpacker\1\);?\n/
10
+
11
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
12
+ "environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin())\n",
13
+ before: "module.exports"
14
+
15
+ say "Adding vue loader to config/webpack/environment.js"
16
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
17
+ "const vue = require('./loaders/vue')\n",
18
+ after: "require('vue-loader')\n"
19
+
20
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
21
+ "environment.loaders.prepend('vue', vue)\n",
22
+ before: "module.exports"
23
+
24
+ say "Updating webpack paths to include .vue file extension"
25
+ insert_into_file Webpacker.config.config_path, "- .vue\n".indent(4), after: /\s+extensions:\n/
26
+
27
+ say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
28
+ copy_file "#{__dir__}/examples/vue/hello_vue.js",
29
+ "#{Webpacker.config.source_entry_path}/hello_vue.js"
30
+
31
+ say "Copying Vue app file to #{Webpacker.config.source_entry_path}"
32
+ copy_file "#{__dir__}/examples/vue/app.vue",
33
+ "#{Webpacker.config.source_path}/app.vue"
34
+
35
+ say "Installing all Vue dependencies"
36
+ run "yarn add vue vue-loader vue-template-compiler"
37
+
38
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
39
+ say "You need to enable unsafe-eval rule.", :yellow
40
+ say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
41
+ say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
42
+ say "if Rails.env.development?", :yellow
43
+ say " policy.script_src :self, :https, :unsafe_eval", :yellow
44
+ say "else", :yellow
45
+ say " policy.script_src :self, :https", :yellow
46
+ say "end", :yellow
47
+ end
48
+
49
+ say "Webpacker now supports Vue.js 🎉", :green
@@ -0,0 +1,42 @@
1
+ installers = {
2
+ "Angular": :angular,
3
+ "Elm": :elm,
4
+ "React": :react,
5
+ "Vue": :vue,
6
+ "Erb": :erb,
7
+ "Coffee": :coffee,
8
+ "Typescript": :typescript,
9
+ "Svelte": :svelte,
10
+ "Stimulus": :stimulus
11
+ }.freeze
12
+
13
+ dependencies = {
14
+ "Angular": [:typescript]
15
+ }
16
+
17
+ bin_path = ENV["BUNDLE_BIN"] || "./bin"
18
+
19
+ namespace :webpacker do
20
+ namespace :install do
21
+ installers.each do |name, task_name|
22
+ desc "Install everything needed for #{name}"
23
+ task task_name => ["webpacker:verify_install"] do
24
+ template = File.expand_path("../install/#{task_name}.rb", __dir__)
25
+ base_path =
26
+ if Rails::VERSION::MAJOR >= 5
27
+ "#{RbConfig.ruby} #{bin_path}/rails app:template"
28
+ else
29
+ "#{RbConfig.ruby} #{bin_path}/rake rails:template"
30
+ end
31
+
32
+ dependencies[name] ||= []
33
+ dependencies[name].each do |dependency|
34
+ dependency_template = File.expand_path("../install/#{dependency}.rb", __dir__)
35
+ system "#{base_path} LOCATION=#{dependency_template}"
36
+ end
37
+
38
+ exec "#{base_path} LOCATION=#{template}"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,13 @@
1
+ binstubs_template_path = File.expand_path("../../install/binstubs.rb", __dir__).freeze
2
+ bin_path = ENV["BUNDLE_BIN"] || "./bin"
3
+
4
+ namespace :webpacker do
5
+ desc "Installs Webpacker binstubs in this application"
6
+ task binstubs: [:check_node, :check_yarn] do
7
+ if Rails::VERSION::MAJOR >= 5
8
+ exec "#{RbConfig.ruby} #{bin_path}/rails app:template LOCATION=#{binstubs_template_path}"
9
+ else
10
+ exec "#{RbConfig.ruby} #{bin_path}/rake rails:template LOCATION=#{binstubs_template_path}"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ namespace :webpacker do
2
+ desc "Verifies that webpack & webpack-dev-server are present."
3
+ task :check_binstubs do
4
+ unless File.exist?("bin/webpack")
5
+ $stderr.puts "webpack binstubs not found.\n"\
6
+ "Have you run rails webpacker:install ?\n"\
7
+ "Make sure the bin directory or binstubs are not included in .gitignore\n"\
8
+ "Exiting!"
9
+ exit!
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,31 @@
1
+ require "semantic_range"
2
+ namespace :webpacker do
3
+ desc "Verifies if Node.js is installed"
4
+ task :check_node do
5
+ begin
6
+ node_version = `node -v || nodejs -v`.strip
7
+ raise Errno::ENOENT if node_version.blank?
8
+
9
+ pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
10
+ node_range = JSON.parse(pkg_path.read)["engines"]["node"]
11
+ is_valid = SemanticRange.satisfies?(node_version, node_range) rescue false
12
+ semver_major = node_version[/\d+/] rescue nil
13
+ is_unstable = semver_major.to_i.odd? rescue false
14
+
15
+ if is_unstable
16
+ $stderr.puts "Warning: you are using an unstable release of Node.js (#{node_version}). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node"
17
+ end
18
+
19
+ unless is_valid
20
+ $stderr.puts "Webpacker requires Node.js \"#{node_range}\" and you are using #{node_version}"
21
+ $stderr.puts "Please upgrade Node.js https://nodejs.org/en/download/"
22
+ $stderr.puts "Exiting!"
23
+ exit!
24
+ end
25
+ rescue Errno::ENOENT
26
+ $stderr.puts "Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/"
27
+ $stderr.puts "Exiting!"
28
+ exit!
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ require "semantic_range"
2
+ namespace :webpacker do
3
+ desc "Verifies if Yarn is installed"
4
+ task :check_yarn do
5
+ begin
6
+ yarn_version = `yarn --version`.strip
7
+ raise Errno::ENOENT if yarn_version.blank?
8
+
9
+ pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
10
+ yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
11
+ is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
12
+ is_unsupported = SemanticRange.satisfies?(yarn_version, ">=4.0.0") rescue false
13
+
14
+ unless is_valid
15
+ $stderr.puts "Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
16
+ if is_unsupported
17
+ $stderr.puts "This version of Webpacker does not support Yarn #{yarn_version}. Please downgrade to a supported version of Yarn https://yarnpkg.com/lang/en/docs/install/"
18
+ else
19
+ $stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
20
+ end
21
+ $stderr.puts "Exiting!"
22
+ exit!
23
+ end
24
+ rescue Errno::ENOENT
25
+ $stderr.puts "Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/"
26
+ $stderr.puts "Exiting!"
27
+ exit!
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ $stdout.sync = true
2
+
3
+ require "webpacker/configuration"
4
+
5
+ namespace :webpacker do
6
+ desc "Remove old compiled webpacks"
7
+ task :clean, [:keep, :age] => ["webpacker:verify_install", :environment] do |_, args|
8
+ Webpacker.ensure_log_goes_to_stdout do
9
+ Webpacker.clean(Integer(args.keep || 2), Integer(args.age || 3600))
10
+ end
11
+ end
12
+ end
13
+
14
+ skip_webpacker_clean = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
15
+
16
+ unless skip_webpacker_clean
17
+ # Run clean if the assets:clean is run
18
+ if Rake::Task.task_defined?("assets:clean")
19
+ Rake::Task["assets:clean"].enhance do
20
+ Rake::Task["webpacker:clean"].invoke
21
+ end
22
+ else
23
+ Rake::Task.define_task("assets:clean" => "webpacker:clean")
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ require "webpacker/configuration"
2
+
3
+ namespace :webpacker do
4
+ desc "Remove the webpack compiled output directory"
5
+ task clobber: ["webpacker:verify_install", :environment] do
6
+ Webpacker.clobber
7
+ $stdout.puts "Removed webpack output path directory #{Webpacker.config.public_output_path}"
8
+ end
9
+ end
10
+
11
+ skip_webpacker_clobber = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
12
+
13
+ unless skip_webpacker_clobber
14
+ # Run clobber if the assets:clobber is run
15
+ if Rake::Task.task_defined?("assets:clobber")
16
+ Rake::Task["assets:clobber"].enhance do
17
+ Rake::Task["webpacker:clobber"].invoke
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ $stdout.sync = true
2
+
3
+ def yarn_install_available?
4
+ rails_major = Rails::VERSION::MAJOR
5
+ rails_minor = Rails::VERSION::MINOR
6
+
7
+ rails_major > 5 || (rails_major == 5 && rails_minor >= 1)
8
+ end
9
+
10
+ def enhance_assets_precompile
11
+ # yarn:install was added in Rails 5.1
12
+ deps = yarn_install_available? ? [] : ["webpacker:yarn_install"]
13
+ Rake::Task["assets:precompile"].enhance(deps) do
14
+ Rake::Task["webpacker:compile"].invoke
15
+ end
16
+ end
17
+
18
+ namespace :webpacker do
19
+ desc "Compile JavaScript packs using webpack for production with digests"
20
+ task compile: ["webpacker:verify_install", :environment] do
21
+ Webpacker.with_node_env(ENV.fetch("NODE_ENV", "production")) do
22
+ Webpacker.ensure_log_goes_to_stdout do
23
+ if Webpacker.compile
24
+ # Successful compilation!
25
+ else
26
+ # Failed compilation
27
+ exit!
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ # Compile packs after we've compiled all other assets during precompilation
35
+ skip_webpacker_precompile = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
36
+
37
+ unless skip_webpacker_precompile
38
+ if Rake::Task.task_defined?("assets:precompile")
39
+ enhance_assets_precompile
40
+ else
41
+ Rake::Task.define_task("assets:precompile" => ["webpacker:yarn_install", "webpacker:compile"])
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ require "webpacker/version"
2
+
3
+ namespace :webpacker do
4
+ desc "Provide information on Webpacker's environment"
5
+ task :info do
6
+ $stdout.puts "Ruby: #{`ruby --version`}"
7
+ $stdout.puts "Rails: #{Rails.version}"
8
+ $stdout.puts "Webpacker: #{Webpacker::VERSION}"
9
+ $stdout.puts "Node: #{`node --version`}"
10
+ $stdout.puts "Yarn: #{`yarn --version`}"
11
+
12
+ $stdout.puts "\n"
13
+ $stdout.puts "@rails/webpacker: \n#{`npm list @rails/webpacker version`}"
14
+
15
+ $stdout.puts "Is bin/webpack present?: #{File.exist? 'bin/webpack'}"
16
+ $stdout.puts "Is bin/webpack-dev-server present?: #{File.exist? 'bin/webpack-dev-server'}"
17
+ $stdout.puts "Is bin/yarn present?: #{File.exist? 'bin/yarn'}"
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ install_template_path = File.expand_path("../../install/template.rb", __dir__).freeze
2
+ bin_path = ENV["BUNDLE_BIN"] || "./bin"
3
+
4
+ namespace :webpacker do
5
+ desc "Install Webpacker in this application"
6
+ task install: [:check_node, :check_yarn] do
7
+ if Rails::VERSION::MAJOR >= 5
8
+ exec "#{RbConfig.ruby} #{bin_path}/rails app:template LOCATION=#{install_template_path}"
9
+ else
10
+ exec "#{RbConfig.ruby} #{bin_path}/rake rails:template LOCATION=#{install_template_path}"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require "webpacker/configuration"
2
+
3
+ namespace :webpacker do
4
+ desc "Verifies if Webpacker is installed"
5
+ task verify_install: [:check_node, :check_yarn, :check_binstubs] do
6
+ unless Webpacker.config.config_path.exist?
7
+ $stderr.puts "Configuration config/webpacker.yml file not found. \n"\
8
+ "Make sure webpacker:install is run successfully before " \
9
+ "running dependent tasks"
10
+ exit!
11
+ end
12
+ end
13
+ end