webpacker-preact 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c0c49265fd07639c3a944c4763a3aee727653844f72ce5ba2c251ccc7036690b
4
+ data.tar.gz: 471e532385c6e0baf63d5be75328077b7dd882e4ef84f6cedf5350998d122e0d
5
+ SHA512:
6
+ metadata.gz: 6f6adca70f112b6c2af71d2ebe347f1361d5c0b4f286f459f4af994f00fc51c11965b49aee5f484223b9748169b2cdf01c90035c8fd7eb8e0b28d260ed0b70ab
7
+ data.tar.gz: 371a748108f0336a1049dd56e8d6a11bc966a7b7fc261a4159946069b0b6ecdf41b33bc7aa65ae66a14b7a13b4e60d0bfacaa76ca96393aca0af58f98521bc03
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 hpneo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Webpacker::Preact
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'webpacker-preact'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install webpacker-preact
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/webpacker/preact .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ module Webpacker
2
+ module Preact
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Webpacker
2
+ module Preact
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Webpacker
2
+ module Preact
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Webpacker
2
+ module Preact
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Webpacker
2
+ module Preact
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Webpacker preact</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "webpacker/preact/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Webpacker::Preact::Engine.routes.draw do
2
+ end
@@ -0,0 +1,80 @@
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
+ modules: 'commonjs'
27
+ }
28
+ ],
29
+ (isProductionEnv || isDevelopmentEnv) && [
30
+ '@babel/preset-env',
31
+ {
32
+ forceAllTransforms: true,
33
+ useBuiltIns: 'entry',
34
+ corejs: 3,
35
+ modules: false,
36
+ exclude: ['transform-typeof-symbol']
37
+ }
38
+ ]
39
+ ].filter(Boolean),
40
+ plugins: [
41
+ 'babel-plugin-macros',
42
+ '@babel/plugin-syntax-dynamic-import',
43
+ isTestEnv && 'babel-plugin-dynamic-import-node',
44
+ '@babel/plugin-transform-destructuring',
45
+ [
46
+ '@babel/plugin-proposal-class-properties',
47
+ {
48
+ loose: true
49
+ }
50
+ ],
51
+ [
52
+ '@babel/plugin-proposal-object-rest-spread',
53
+ {
54
+ useBuiltIns: true
55
+ }
56
+ ],
57
+ [
58
+ '@babel/plugin-transform-runtime',
59
+ {
60
+ helpers: false,
61
+ regenerator: true,
62
+ corejs: false
63
+ }
64
+ ],
65
+ [
66
+ '@babel/plugin-transform-regenerator',
67
+ {
68
+ async: false
69
+ }
70
+ ],
71
+ isProductionEnv && [
72
+ 'babel-plugin-transform-react-remove-prop-types',
73
+ {
74
+ removeImport: true
75
+ }
76
+ ],
77
+ ['transform-react-jsx', { pragma: 'h' }]
78
+ ].filter(Boolean)
79
+ }
80
+ }
@@ -0,0 +1,12 @@
1
+ import { h, render } from 'preact';
2
+
3
+ const Hello = props => (
4
+ <div>Hello {props.name}!</div>
5
+ )
6
+
7
+ document.addEventListener('DOMContentLoaded', () => {
8
+ render(
9
+ <Hello name="Preact" />,
10
+ document.body.appendChild(document.createElement('div')),
11
+ )
12
+ });
@@ -0,0 +1,13 @@
1
+ require "webpacker/configuration"
2
+ require "fileutils"
3
+
4
+ say "Copying babel.config.js to app root directory"
5
+ copy_file "#{__dir__}/examples/preact/babel.config.js", "babel.config.js"
6
+
7
+ say "Copying preact example entry file to #{Webpacker.config.source_entry_path}"
8
+ copy_file "#{__dir__}/examples/preact/hello_preact.js", "#{Webpacker.config.source_entry_path}/hello_preact.js"
9
+
10
+ say "Installing all preact dependencies"
11
+ run "yarn add babel-plugin-transform-react-jsx preact"
12
+
13
+ say "Webpacker now supports Preact.js 🎉", :green
@@ -0,0 +1,16 @@
1
+ bin_path = ENV["BUNDLE_BIN"] || Rails.root.join("bin")
2
+
3
+ namespace :webpacker do
4
+ desc "Install everything needed for Preact"
5
+ task "install:preact": ["webpacker:check_yarn"] do |task|
6
+ template = File.expand_path("../../install/template.rb", __dir__)
7
+ base_path =
8
+ if Rails::VERSION::MAJOR >= 5
9
+ "#{RbConfig.ruby} #{bin_path}/rails app:template"
10
+ else
11
+ "#{RbConfig.ruby} #{bin_path}/rake rails:template"
12
+ end
13
+
14
+ exec "#{base_path} LOCATION=#{template}"
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ require "webpacker/preact/version"
2
+ require "webpacker/preact/engine"
3
+
4
+ module Webpacker
5
+ module Preact
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Webpacker
2
+ module Preact
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Webpacker::Preact
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Webpacker
2
+ module Preact
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webpacker-preact
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - hpneo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: webpacker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.76'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.76'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-airbnb
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.2
69
+ description:
70
+ email:
71
+ - hpneo@hotmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - MIT-LICENSE
77
+ - README.md
78
+ - Rakefile
79
+ - app/assets/config/webpacker_preact_manifest.js
80
+ - app/assets/stylesheets/webpacker/preact/application.css
81
+ - app/controllers/webpacker/preact/application_controller.rb
82
+ - app/helpers/webpacker/preact/application_helper.rb
83
+ - app/jobs/webpacker/preact/application_job.rb
84
+ - app/mailers/webpacker/preact/application_mailer.rb
85
+ - app/models/webpacker/preact/application_record.rb
86
+ - app/views/layouts/webpacker/preact/application.html.erb
87
+ - config/routes.rb
88
+ - lib/install/examples/preact/babel.config.js
89
+ - lib/install/examples/preact/hello_preact.js
90
+ - lib/install/template.rb
91
+ - lib/tasks/webpacker/preact_tasks.rake
92
+ - lib/webpacker/preact.rb
93
+ - lib/webpacker/preact/engine.rb
94
+ - lib/webpacker/preact/version.rb
95
+ homepage: https://github.com/hpneo/webpacker-preact
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ allowed_push_host: https://rubygems.org
100
+ homepage_uri: https://github.com/hpneo/webpacker-preact
101
+ source_code_uri: https://github.com/hpneo/webpacker-preact
102
+ changelog_uri: https://github.com/hpneo/webpacker-preact/blob/master/CHANGELOG.md
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.1.4
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Preact integration for Webpacker.
122
+ test_files: []