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.
- checksums.yaml +4 -4
- data/.eslintignore +4 -0
- data/.eslintrc.js +14 -0
- data/.gitignore +11 -11
- data/.node-version +1 -0
- data/.rubocop.yml +125 -0
- data/.travis.yml +54 -5
- data/CHANGELOG.jetpacker.md +7 -0
- data/CHANGELOG.md +1000 -0
- data/CONTRIBUTING.md +33 -0
- data/Gemfile +9 -3
- data/Gemfile.lock +157 -21
- data/MIT-LICENSE +20 -0
- data/README.md +671 -16
- data/Rakefile +8 -3
- data/docs/assets.md +119 -0
- data/docs/cloud9.md +310 -0
- data/docs/css.md +253 -0
- data/docs/deployment.md +130 -0
- data/docs/docker.md +68 -0
- data/docs/engines.md +200 -0
- data/docs/env.md +65 -0
- data/docs/es6.md +72 -0
- data/docs/folder-structure.md +66 -0
- data/docs/misc.md +23 -0
- data/docs/props.md +223 -0
- data/docs/testing.md +137 -0
- data/docs/troubleshooting.md +156 -0
- data/docs/typescript.md +126 -0
- data/docs/v4-upgrade.md +142 -0
- data/docs/webpack-dev-server.md +92 -0
- data/docs/webpack.md +364 -0
- data/docs/yarn.md +23 -0
- data/gemfiles/Gemfile-rails-edge +12 -0
- data/gemfiles/Gemfile-rails.4.2.x +9 -0
- data/gemfiles/Gemfile-rails.5.0.x +9 -0
- data/gemfiles/Gemfile-rails.5.1.x +9 -0
- data/gemfiles/Gemfile-rails.5.2.x +9 -0
- data/gemfiles/Gemfile-rails.6.0.x +9 -0
- data/jetpacker.gemspec +28 -22
- data/lib/install/angular.rb +23 -0
- data/lib/install/bin/webpack +18 -0
- data/lib/install/bin/webpack-dev-server +18 -0
- data/lib/install/binstubs.rb +4 -0
- data/lib/install/coffee.rb +25 -0
- data/lib/install/config/.browserslistrc +1 -0
- data/lib/install/config/babel.config.js +72 -0
- data/lib/install/config/postcss.config.js +12 -0
- data/lib/install/config/webpack/development.js +5 -0
- data/lib/install/config/webpack/environment.js +3 -0
- data/lib/install/config/webpack/production.js +5 -0
- data/lib/install/config/webpack/test.js +5 -0
- data/lib/install/config/webpacker.yml +96 -0
- data/lib/install/elm.rb +39 -0
- data/lib/install/erb.rb +25 -0
- data/lib/install/examples/angular/hello_angular.js +7 -0
- data/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
- data/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
- data/lib/install/examples/angular/hello_angular/index.ts +8 -0
- data/lib/install/examples/angular/hello_angular/polyfills.ts +73 -0
- data/lib/install/examples/coffee/hello_coffee.coffee +4 -0
- data/lib/install/examples/elm/Main.elm +55 -0
- data/lib/install/examples/elm/hello_elm.js +16 -0
- data/lib/install/examples/erb/hello_erb.js.erb +6 -0
- data/lib/install/examples/react/babel.config.js +87 -0
- data/lib/install/examples/react/hello_react.jsx +26 -0
- data/lib/install/examples/react/tsconfig.json +20 -0
- data/lib/install/examples/stimulus/application.js +1 -0
- data/lib/install/examples/stimulus/controllers/hello_controller.js +18 -0
- data/lib/install/examples/stimulus/controllers/index.js +9 -0
- data/lib/install/examples/svelte/app.svelte +11 -0
- data/lib/install/examples/svelte/hello_svelte.js +20 -0
- data/lib/install/examples/typescript/hello_typescript.ts +4 -0
- data/lib/install/examples/typescript/tsconfig.json +23 -0
- data/lib/install/examples/vue/app.vue +22 -0
- data/lib/install/examples/vue/hello_vue.js +72 -0
- data/lib/install/javascript/packs/application.js +18 -0
- data/lib/install/loaders/coffee.js +6 -0
- data/lib/install/loaders/elm.js +25 -0
- data/lib/install/loaders/erb.js +11 -0
- data/lib/install/loaders/svelte.js +9 -0
- data/lib/install/loaders/typescript.js +11 -0
- data/lib/install/loaders/vue.js +6 -0
- data/lib/install/react.rb +18 -0
- data/lib/install/stimulus.rb +12 -0
- data/lib/install/svelte.rb +29 -0
- data/lib/install/template.rb +55 -0
- data/lib/install/typescript.rb +46 -0
- data/lib/install/vue.rb +49 -0
- data/lib/jetpacker/version.rb +2 -1
- data/lib/tasks/installers.rake +37 -0
- data/lib/tasks/webpacker.rake +28 -0
- data/lib/tasks/webpacker/binstubs.rake +11 -0
- data/lib/tasks/webpacker/check_binstubs.rake +12 -0
- data/lib/tasks/webpacker/check_node.rake +24 -0
- data/lib/tasks/webpacker/check_yarn.rake +24 -0
- data/lib/tasks/webpacker/clean.rake +21 -0
- data/lib/tasks/webpacker/clobber.rake +16 -0
- data/lib/tasks/webpacker/compile.rake +43 -0
- data/lib/tasks/webpacker/info.rake +20 -0
- data/lib/tasks/webpacker/install.rake +13 -0
- data/lib/tasks/webpacker/verify_install.rake +13 -0
- data/lib/tasks/webpacker/yarn_install.rake +21 -0
- data/lib/webpacker.rb +46 -0
- data/lib/webpacker/commands.rb +50 -0
- data/lib/webpacker/compiler.rb +107 -0
- data/lib/webpacker/configuration.rb +113 -0
- data/lib/webpacker/dev_server.rb +66 -0
- data/lib/webpacker/dev_server_proxy.rb +31 -0
- data/lib/webpacker/dev_server_runner.rb +72 -0
- data/lib/webpacker/env.rb +39 -0
- data/lib/webpacker/helper.rb +176 -0
- data/lib/webpacker/instance.rb +37 -0
- data/lib/webpacker/manifest.rb +118 -0
- data/lib/webpacker/railtie.rb +98 -0
- data/lib/webpacker/rake_tasks.rb +6 -0
- data/lib/webpacker/runner.rb +22 -0
- data/lib/webpacker/version.rb +4 -0
- data/lib/webpacker/webpack_runner.rb +32 -0
- data/package.json +82 -0
- data/package/__tests__/config.js +55 -0
- data/package/__tests__/dev_server.js +43 -0
- data/package/__tests__/development.js +30 -0
- data/package/__tests__/env.js +46 -0
- data/package/__tests__/production.js +29 -0
- data/package/__tests__/staging.js +29 -0
- data/package/__tests__/test.js +26 -0
- data/package/config.js +37 -0
- data/package/config_types/__tests__/config_list.js +118 -0
- data/package/config_types/__tests__/config_object.js +43 -0
- data/package/config_types/config_list.js +75 -0
- data/package/config_types/config_object.js +55 -0
- data/package/config_types/index.js +7 -0
- data/package/dev_server.js +20 -0
- data/package/env.js +19 -0
- data/package/environments/__tests__/base.js +74 -0
- data/package/environments/base.js +166 -0
- data/package/environments/development.js +51 -0
- data/package/environments/production.js +79 -0
- data/package/environments/test.js +3 -0
- data/package/index.js +24 -0
- data/package/rules/babel.js +21 -0
- data/package/rules/css.js +3 -0
- data/package/rules/file.js +20 -0
- data/package/rules/index.js +20 -0
- data/package/rules/module.css.js +3 -0
- data/package/rules/module.sass.js +8 -0
- data/package/rules/node_modules.js +24 -0
- data/package/rules/sass.js +8 -0
- data/package/utils/__tests__/deep_assign.js +32 -0
- data/package/utils/__tests__/deep_merge.js +10 -0
- data/package/utils/__tests__/get_style_rule.js +65 -0
- data/package/utils/__tests__/objectify.js +9 -0
- data/package/utils/deep_assign.js +22 -0
- data/package/utils/deep_merge.js +22 -0
- data/package/utils/get_style_rule.js +45 -0
- data/package/utils/helpers.js +58 -0
- data/package/utils/objectify.js +3 -0
- data/test/command_test.rb +33 -0
- data/test/compiler_test.rb +75 -0
- data/test/configuration_test.rb +108 -0
- data/test/dev_server_runner_test.rb +51 -0
- data/test/dev_server_test.rb +47 -0
- data/test/env_test.rb +23 -0
- data/test/helper_test.rb +142 -0
- data/test/manifest_test.rb +42 -0
- data/test/rake_tasks_test.rb +69 -0
- data/test/test_app/Rakefile +3 -0
- data/test/test_app/app/javascript/packs/application.js +10 -0
- data/test/test_app/bin/webpack +14 -0
- data/test/test_app/bin/webpack-dev-server +14 -0
- data/test/test_app/config.ru +5 -0
- data/test/test_app/config/application.rb +12 -0
- data/test/test_app/config/environment.rb +4 -0
- data/test/test_app/config/webpack/development.js +0 -0
- data/test/test_app/config/webpacker.yml +97 -0
- data/test/test_app/config/webpacker_public_root.yml +19 -0
- data/test/test_app/package.json +13 -0
- data/test/test_app/public/packs/manifest.json +31 -0
- data/test/test_app/yarn.lock +11 -0
- data/test/test_helper.rb +33 -0
- data/test/webpack_runner_test.rb +51 -0
- data/test/webpacker_test.rb +13 -0
- data/yarn.lock +8321 -0
- metadata +267 -29
- data/.rspec +0 -3
- data/LICENSE.txt +0 -21
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/jetpacker.rb +0 -6
data/jetpacker.gemspec
CHANGED
|
@@ -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 |
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
26
|
-
|
|
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,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,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
|
data/lib/install/elm.rb
ADDED
|
@@ -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
|
data/lib/install/erb.rb
ADDED
|
@@ -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
|