webpacker_lite 0.0.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 503a0b5821e1c934b561fe9ef5d645485363adda
4
+ data.tar.gz: 886621d91d891e8b2d83fdbbf644be7a2d50e31c
5
+ SHA512:
6
+ metadata.gz: 25372b6d5549893a0d4ec67bd7b8d648950f71e6710b3d5c7f7341f32de1c0461c6ea1a3c48bae5b1ba35632269eb04ffb3160a98f060e4200629831565c6136
7
+ data.tar.gz: bd153b262f5683e1b534dd49301334047ca88b900a49116f27c491019b676f0a74a90d4597168f43ef15e6b4cef7d2ec45407d1ceb8116a1ea1d512925d18948
@@ -0,0 +1,2 @@
1
+ /.bundle
2
+ node_modules
@@ -0,0 +1,124 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+ Exclude:
7
+ - 'lib/install/templates/**'
8
+ - 'vendor/**/*'
9
+ - 'node_modules/**/*'
10
+
11
+ # Prefer &&/|| over and/or.
12
+ Style/AndOr:
13
+ Enabled: true
14
+
15
+ # Do not use braces for hash literals when they are the last argument of a
16
+ # method call.
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: true
19
+
20
+ # Align `when` with `case`.
21
+ Style/CaseIndentation:
22
+ Enabled: true
23
+
24
+ # Align comments with method definitions.
25
+ Style/CommentIndentation:
26
+ Enabled: true
27
+
28
+ # No extra empty lines.
29
+ Style/EmptyLines:
30
+ Enabled: true
31
+
32
+ # In a regular class definition, no empty lines around the body.
33
+ Style/EmptyLinesAroundClassBody:
34
+ Enabled: true
35
+
36
+ # In a regular method definition, no empty lines around the body.
37
+ Style/EmptyLinesAroundMethodBody:
38
+ Enabled: true
39
+
40
+ # In a regular module definition, no empty lines around the body.
41
+ Style/EmptyLinesAroundModuleBody:
42
+ Enabled: true
43
+
44
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
45
+ Style/HashSyntax:
46
+ Enabled: true
47
+
48
+ # Method definitions after `private` or `protected` isolated calls need one
49
+ # extra level of indentation.
50
+ Style/IndentationConsistency:
51
+ Enabled: true
52
+ EnforcedStyle: rails
53
+
54
+ # Two spaces, no tabs (for indentation).
55
+ Style/IndentationWidth:
56
+ Enabled: true
57
+
58
+ Style/SpaceAfterColon:
59
+ Enabled: true
60
+
61
+ Style/SpaceAfterComma:
62
+ Enabled: true
63
+
64
+ Style/SpaceAroundEqualsInParameterDefault:
65
+ Enabled: true
66
+
67
+ Style/SpaceAroundKeyword:
68
+ Enabled: true
69
+
70
+ Style/SpaceAroundOperators:
71
+ Enabled: true
72
+
73
+ Style/SpaceBeforeFirstArg:
74
+ Enabled: true
75
+
76
+ # Defining a method with parameters needs parentheses.
77
+ Style/MethodDefParentheses:
78
+ Enabled: true
79
+
80
+ # Use `foo {}` not `foo{}`.
81
+ Style/SpaceBeforeBlockBraces:
82
+ Enabled: true
83
+
84
+ # Use `foo { bar }` not `foo {bar}`.
85
+ Style/SpaceInsideBlockBraces:
86
+ Enabled: true
87
+
88
+ # Use `{ a: 1 }` not `{a:1}`.
89
+ Style/SpaceInsideHashLiteralBraces:
90
+ Enabled: true
91
+
92
+ Style/SpaceInsideParens:
93
+ Enabled: true
94
+
95
+ # Check quotes usage according to lint rule below.
96
+ Style/StringLiterals:
97
+ Enabled: true
98
+ EnforcedStyle: double_quotes
99
+
100
+ # Detect hard tabs, no hard tabs.
101
+ Style/Tab:
102
+ Enabled: true
103
+
104
+ # Blank lines should not have any spaces.
105
+ Style/TrailingBlankLines:
106
+ Enabled: true
107
+
108
+ # No trailing whitespace.
109
+ Style/TrailingWhitespace:
110
+ Enabled: true
111
+
112
+ # Use quotes for string literals when they are enough.
113
+ Style/UnneededPercentQ:
114
+ Enabled: true
115
+
116
+ # Align `end` with the matching keyword or starting expression except for
117
+ # assignments, where it should be aligned with the LHS.
118
+ Lint/EndAlignment:
119
+ Enabled: true
120
+ EnforcedStyleAlignWith: variable
121
+
122
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
123
+ Lint/RequireParentheses:
124
+ Enabled: true
@@ -0,0 +1,21 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.6
5
+ - 2.3.3
6
+ - 2.4.1
7
+ cache:
8
+ bundler: true
9
+ directories:
10
+ - node_modules
11
+ yarn: true
12
+
13
+ install:
14
+ - gem install rubocop
15
+ - nvm install node
16
+ - node -v
17
+ - npm i -g yarn
18
+ - yarn
19
+ script:
20
+ - yarn lint
21
+ - rubocop
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ webpacker_lite (0.0.2)
5
+ activesupport (>= 4.2)
6
+ multi_json (~> 1.2)
7
+ railties (>= 4.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (5.0.2)
13
+ actionview (= 5.0.2)
14
+ activesupport (= 5.0.2)
15
+ rack (~> 2.0)
16
+ rack-test (~> 0.6.3)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
+ actionview (5.0.2)
20
+ activesupport (= 5.0.2)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ rails-dom-testing (~> 2.0)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
25
+ activesupport (5.0.2)
26
+ concurrent-ruby (~> 1.0, >= 1.0.2)
27
+ i18n (~> 0.7)
28
+ minitest (~> 5.1)
29
+ tzinfo (~> 1.1)
30
+ builder (3.2.3)
31
+ concurrent-ruby (1.0.5)
32
+ erubis (2.7.0)
33
+ i18n (0.8.1)
34
+ loofah (2.0.3)
35
+ nokogiri (>= 1.5.9)
36
+ method_source (0.8.2)
37
+ mini_portile2 (2.1.0)
38
+ minitest (5.10.1)
39
+ multi_json (1.12.1)
40
+ nokogiri (1.7.1)
41
+ mini_portile2 (~> 2.1.0)
42
+ rack (2.0.1)
43
+ rack-test (0.6.3)
44
+ rack (>= 1.0)
45
+ rails-dom-testing (2.0.2)
46
+ activesupport (>= 4.2.0, < 6.0)
47
+ nokogiri (~> 1.6)
48
+ rails-html-sanitizer (1.0.3)
49
+ loofah (~> 2.0)
50
+ railties (5.0.2)
51
+ actionpack (= 5.0.2)
52
+ activesupport (= 5.0.2)
53
+ method_source
54
+ rake (>= 0.8.7)
55
+ thor (>= 0.18.1, < 2.0)
56
+ rake (12.0.0)
57
+ thor (0.19.4)
58
+ thread_safe (0.3.6)
59
+ tzinfo (1.2.3)
60
+ thread_safe (~> 0.1)
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ bundler (~> 1.12)
67
+ webpacker_lite!
68
+
69
+ BUNDLED WITH
70
+ 1.14.6
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2016 David Heinemeier Hansson, Basecamp,
2
+ 2017 Justin Gordon, ShakaCode
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ # Webpacker Lite
2
+ ![travis-ci status](https://api.travis-ci.org/rails/webpacker_lite.svg?branch=master)
3
+ [![node.js](https://img.shields.io/badge/node-%3E%3D%206.4.0-brightgreen.svg)](https://nodejs.org/en/)
4
+ [![Gem](https://img.shields.io/gem/v/webpacker_lite.svg)](https://github.com/shakacode/webpacker_lite)
5
+
6
+ Webpacker Lite provides the webpack enabled asset helpers from [Webpacker](https://github.com/rails/webpacker).
7
+ [React on Rails](https://github.com/shakacode/react_on_rails) will soon support using Webpacker Lite.
8
+
9
+ ## Prerequisites
10
+
11
+ * Ruby 2.2+
12
+ * Rails 4.2+
13
+ * Node.js 6.4.0+
14
+ * Yarn
15
+
16
+ ## Installation
17
+
18
+ WebpackerLite is currently compatible with Rails 4.2+, but there's no guarantee it will still be
19
+ in the future.
20
+
21
+ ## Overview
22
+
23
+ 1. Configure the location of your Webpack output in the `config/webpack/paths.yml` file.
24
+ `webpack_ouput: public/assets/webpack` is the default.
25
+ 2. Configure your Webpack scripts to:
26
+ 1. Use the manifest plugin to generate a manifest
27
+ 2. Write output to the directory that you configured in your paths.yml file.
28
+ 3. Use the asset helpers on your layouts to provide the webpack generated files:
29
+ ```erb
30
+ <%# app/views/layouts/application.html.erb %>
31
+ <%= javascript_pack_tag 'main' %>
32
+ <%= stylesheet_pack_tag 'main' %>
33
+ ```
34
+
35
+ ## Hot Reloading Config
36
+ Similary, you can also control and configure `webpack-dev-server` settings from
37
+ `config/webpack/development.server.yml` file
38
+
39
+ ```yml
40
+ # config/webpack/development.server.yml
41
+ enabled: true
42
+ host: localhost
43
+ port: 8080
44
+ ```
45
+
46
+ ## Getting asset path
47
+
48
+ Webpacker provides `asset_pack_path` helper to get the path of any given asset that's been compiled by webpack.
49
+
50
+ For example, if you want to create a `<link rel="prefetch">` or `<img />`
51
+ for an asset used in your pack code you can reference them like this in your view,
52
+
53
+ ```erb
54
+ <img src="<%= asset_pack_path 'calendar.png' %>" />
55
+ <% # => <img src="/packs/calendar.png" /> %>
56
+ ```
57
+
58
+ ## Example for Development vs Hot Reloading vs Production Mode
59
+ ```html
60
+ <!-- In development mode with webpack-dev-server -->
61
+ <script src="http://localhost:8080/main.js"></script>
62
+ <link rel="stylesheet" media="screen" href="http://localhost:8080/main.css">
63
+ <!-- In development mode -->
64
+ <script src="/packs/main.js"></script>
65
+ <link rel="stylesheet" media="screen" href="/packs/main.css">
66
+ <!-- In production mode -->
67
+ <script src="/packs/main-0bd141f6d9360cf4a7f5.js"></script>
68
+ <link rel="stylesheet" media="screen" href="/packs/main-dc02976b5f94b507e3b6.css">
69
+ ```
70
+
71
+ ## License
72
+ Webpacker is released under the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ # Restart webpack-dev-server if you make changes here
2
+ default: &default
3
+ enabled: true
4
+ host: localhost
5
+ port: 8080
6
+
7
+ development:
8
+ <<: *default
9
+
10
+ test:
11
+ <<: *default
12
+ enabled: false
13
+
14
+ production:
15
+ <<: *default
16
+ enabled: false
@@ -0,0 +1,31 @@
1
+ # Restart webpack-watcher or webpack-dev-server if you make changes here
2
+ default: &default
3
+ config: config/webpack
4
+ entry: packs
5
+ output: public
6
+ manifest: manifest.json
7
+ node_modules: node_modules
8
+ source: app/javascript
9
+ extensions:
10
+ - .coffee
11
+ - .js
12
+ - .jsx
13
+ - .ts
14
+ - .vue
15
+ - .sass
16
+ - .scss
17
+ - .css
18
+ - .png
19
+ - .svg
20
+ - .gif
21
+ - .jpeg
22
+
23
+ development:
24
+ <<: *default
25
+
26
+ test:
27
+ <<: *default
28
+ manifest: manifest-test.json
29
+
30
+ production:
31
+ <<: *default
@@ -0,0 +1,10 @@
1
+ # Install webpacker
2
+
3
+ puts "Copying webpack core config and loaders"
4
+ directory "#{__dir__}/config/webpack", "config/webpack"
5
+
6
+ append_to_file ".gitignore", <<-EOS
7
+ /public/webpack
8
+ EOS
9
+
10
+ puts "Webpacker Lite successfully installed 🎉 🍰"
@@ -0,0 +1,13 @@
1
+ tasks = {
2
+ "webpacker_lite:install" => "Installs and setup webpack with yarn",
3
+ "webpacker_lite:compile" => "Compiles webpack bundles based on environment",
4
+ "webpacker_lite:check_node" => "Verifies if Node.js is installed",
5
+ "webpacker_lite:check_yarn" => "Verifies if yarn is installed",
6
+ "webpacker_lite:verify_install" => "Verifies if webpacker is installed",
7
+ }.freeze
8
+
9
+ desc "Lists all available tasks in webpacker_lite"
10
+ task :webpacker_lite do
11
+ puts "Available webpacker_lite tasks are:"
12
+ tasks.each { |task, message| puts task.ljust(30) + message }
13
+ end
@@ -0,0 +1,19 @@
1
+ namespace :webpacker_lite do
2
+ desc "Verifies if Node.js is installed"
3
+ task :check_node do
4
+ begin
5
+ node_version = `node -v`
6
+ required_node_version = "6.4"
7
+
8
+ raise Errno::ENOENT if node_version.blank?
9
+ if Gem::Version.new(node_version.strip.tr("v", "")) < Gem::Version.new(required_node_version)
10
+ puts "WebpackerLite requires Node.js >= v#{required_node_version} and you are using #{node_version}"
11
+ puts "Please upgrade Node.js https://nodejs.org/en/download/"
12
+ puts "Exiting!" && exit!
13
+ end
14
+ rescue Errno::ENOENT
15
+ puts "Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/"
16
+ puts "Exiting!" && exit!
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ namespace :webpacker_lite do
2
+ desc "Verifies if yarn is installed"
3
+ task :check_yarn do
4
+ begin
5
+ version = `yarn --version`
6
+ raise Errno::ENOENT if version.blank?
7
+ rescue Errno::ENOENT
8
+ puts "WebpackerLite requires yarn. Please download and install Yarn https://yarnpkg.com/lang/en/docs/install/"
9
+ puts "Exiting!" && exit!
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ WEBPACKER_APP_TEMPLATE_PATH = File.expand_path("../../install/template.rb", __dir__)
2
+
3
+ namespace :webpacker_lite do
4
+ desc "Install webpacker lite in this application"
5
+ task install: [:check_node, :check_yarn] do
6
+ if Rails::VERSION::MAJOR >= 5
7
+ exec "./bin/rails app:template LOCATION=#{WEBPACKER_APP_TEMPLATE_PATH}"
8
+ else
9
+ exec "./bin/rake rails:template LOCATION=#{WEBPACKER_APP_TEMPLATE_PATH}"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require "webpacker_lite/configuration"
2
+
3
+ namespace :webpacker_lite do
4
+ desc "Verifies if webpacker_lite is installed"
5
+ task verify_install: [:check_node, :check_yarn] do
6
+ if File.exist?(WebpackerLite::Configuration.file_path)
7
+ puts "WebpackerLite is installed 🎉 🍰"
8
+ puts "Using #{WebpackerLite::Configuration.file_path} file for setting up webpack paths"
9
+ else
10
+ puts "Configuration config/webpack/paths.yml file not found. \n"\
11
+ "Make sure webpacker_lite:install is run successfully before " \
12
+ "running dependent tasks"
13
+ exit!
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ module WebpackerLite
2
+ def self.bootstrap
3
+ WebpackerLite::Env.load
4
+ WebpackerLite::Configuration.load
5
+ WebpackerLite::Manifest.load
6
+ end
7
+ end
8
+
9
+ require "webpacker_lite/railtie" if defined?(Rails)
@@ -0,0 +1,39 @@
1
+ # Loads webpacker configuration from config/webpack/paths.yml
2
+ require "webpacker_lite/file_loader"
3
+ require "webpacker_lite/env"
4
+
5
+ class WebpackerLite::Configuration < WebpackerLite::FileLoader
6
+ class << self
7
+ def config_path
8
+ Rails.root.join(paths.fetch(:config, "config/webpack"))
9
+ end
10
+
11
+ def file_path
12
+ Rails.root.join("config", "webpack", "paths.yml")
13
+ end
14
+
15
+ def manifest_path
16
+ Rails.root.join(output_path, paths.fetch(:manifest, "manifest.json"))
17
+ end
18
+
19
+ def output_path
20
+ Rails.root.join(paths.fetch(:output, "public"), paths.fetch(:assets, "assets/webpack"))
21
+ end
22
+
23
+ def paths
24
+ load if WebpackerLite::Env.development?
25
+ raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Configuration.load must be called first") unless instance
26
+ instance.data
27
+ end
28
+
29
+ def source_path
30
+ Rails.root.join(paths.fetch(:source, "app/javascript"))
31
+ end
32
+ end
33
+
34
+ private
35
+ def load
36
+ return super unless File.exist?(@path)
37
+ HashWithIndifferentAccess.new(YAML.load(File.read(@path))[WebpackerLite::Env.current])
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ # Singleton registry for determining NODE_ENV from config/webpack/paths.yml
2
+ require "webpacker_lite/file_loader"
3
+
4
+ class WebpackerLite::Env < WebpackerLite::FileLoader
5
+ class << self
6
+ def current
7
+ raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Env.load must be called first") unless instance
8
+ instance.data
9
+ end
10
+
11
+ def development?
12
+ current == "development"
13
+ end
14
+
15
+ def file_path
16
+ Rails.root.join("config", "webpack", "paths.yml")
17
+ end
18
+ end
19
+
20
+ private
21
+ def load
22
+ environments = File.exist?(@path) ? YAML.load(File.read(@path)).keys : [].freeze
23
+ return ENV["NODE_ENV"] if environments.include?(ENV["NODE_ENV"])
24
+ return Rails.env if environments.include?(Rails.env)
25
+ "production"
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ # Provides a base singleton-configuration pattern for loading a file, given a path
2
+ class WebpackerLite::FileLoader
3
+ class NotFoundError < StandardError; end
4
+ class FileLoaderError < StandardError; end
5
+
6
+ class_attribute :instance
7
+ attr_accessor :data
8
+
9
+ class << self
10
+ def load(path = file_path)
11
+ self.instance = new(path)
12
+ end
13
+ end
14
+
15
+ private
16
+ def initialize(path)
17
+ @path = path
18
+ @data = load
19
+ end
20
+
21
+ def load
22
+ {}.freeze
23
+ end
24
+ end
@@ -0,0 +1,49 @@
1
+ require "webpacker_lite/manifest"
2
+
3
+ module WebpackerLite::Helper
4
+ # Computes the full path for a given webpacker asset.
5
+ # Return relative path using manifest.json and passes it to asset_url helper
6
+ # This will use asset_path internally, so most of their behaviors will be the same.
7
+ # Examples:
8
+ #
9
+ # In development mode:
10
+ # <%= asset_pack_path 'calendar.js' %> # => "/packs/calendar.js"
11
+ # In production mode:
12
+ # <%= asset_pack_path 'calendar.css' %> # => "/packs/calendar-1016838bab065ae1e122.css"
13
+ def asset_pack_path(name, **options)
14
+ asset_path(WebpackerLite::Manifest.lookup(name), **options)
15
+ end
16
+ # Creates a script tag that references the named pack file, as compiled by Webpack per the entries list
17
+ # in config/webpack/shared.js. By default, this list is auto-generated to match everything in
18
+ # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
19
+ #
20
+ # Examples:
21
+ #
22
+ # # In development mode:
23
+ # <%= javascript_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
24
+ # <script src="/packs/calendar.js" data-turbolinks-track="reload"></script>
25
+ #
26
+ # # In production mode:
27
+ # <%= javascript_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
28
+ # <script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
29
+ def javascript_pack_tag(name, **options)
30
+ javascript_include_tag(WebpackerLite::Manifest.lookup("#{name}#{compute_asset_extname(name, type: :javascript)}"), **options)
31
+ end
32
+
33
+ # Creates a link tag that references the named pack file, as compiled by Webpack per the entries list
34
+ # in config/webpack/shared.js. By default, this list is auto-generated to match everything in
35
+ # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
36
+ #
37
+ # Examples:
38
+ #
39
+ # # In development mode:
40
+ # <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
41
+ # <link rel="stylesheet" media="screen" href="/packs/calendar.css" data-turbolinks-track="reload" />
42
+ #
43
+ # # In production mode:
44
+ # <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
45
+ # <link rel="stylesheet" media="screen" href="/packs/calendar-1016838bab065ae1e122.css" data-turbolinks-track="reload" />
46
+ def stylesheet_pack_tag(name, **options)
47
+ stylesheet_link_tag(WebpackerLite::Manifest.lookup("#{name}#{compute_asset_extname(name, type: :stylesheet)}"), **options)
48
+ end
49
+ end
@@ -0,0 +1,30 @@
1
+ # Singleton registry for accessing the packs path using generated manifest.
2
+ # This allows javascript_pack_tag, stylesheet_pack_tag, asset_pack_path to take a reference to,
3
+ # say, "calendar.js" or "calendar.css" and turn it into "/packs/calendar.js" or
4
+ # "/packs/calendar.css" in development. In production mode, it returns compiles
5
+ # files, # "/packs/calendar-1016838bab065ae1e314.js" and
6
+ # "/packs/calendar-1016838bab065ae1e314.css" for long-term caching
7
+
8
+ require "webpacker_lite/file_loader"
9
+ require "webpacker_lite/env"
10
+ require "webpacker_lite/configuration"
11
+
12
+ class WebpackerLite::Manifest < WebpackerLite::FileLoader
13
+ class << self
14
+ def file_path
15
+ WebpackerLite::Configuration.manifest_path
16
+ end
17
+
18
+ def lookup(name)
19
+ load if WebpackerLite::Env.development?
20
+ raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Manifest.load must be called first") unless instance
21
+ instance.data[name.to_s] || raise(WebpackerLite::FileLoader::NotFoundError.new("Can't find #{name} in #{file_path}. Is webpack still compiling?"))
22
+ end
23
+ end
24
+
25
+ private
26
+ def load
27
+ return super unless File.exist?(@path)
28
+ JSON.parse(File.read(@path))
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ require "rails/railtie"
2
+
3
+ require "webpacker_lite/helper"
4
+
5
+ class WebpackerLite::Engine < ::Rails::Engine
6
+ initializer :webpacker_lite do |app|
7
+ ActiveSupport.on_load :action_controller do
8
+ ActionController::Base.helper WebpackerLite::Helper
9
+ end
10
+
11
+ WebpackerLite.bootstrap
12
+ Spring.after_fork { WebpackerLite.bootstrap } if defined?(Spring)
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module WebpackerLite
2
+ VERSION = "0.0.3".freeze
3
+ end
@@ -0,0 +1,23 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "webpacker_lite/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "webpacker_lite"
6
+ s.version = WebpackerLite::VERSION
7
+ s.authors = "David Heinemeier Hansson, Justin Gordon"
8
+ s.email = "justin@shakacode.com"
9
+ s.summary = "Asset Helpers for Webpack"
10
+ s.homepage = "https://github.com/shakacode/webpacker_lite"
11
+ s.license = "MIT"
12
+
13
+ s.required_ruby_version = ">= 1.9.3"
14
+
15
+ s.add_dependency "activesupport", ">= 4.2"
16
+ s.add_dependency "multi_json", "~> 1.2"
17
+ s.add_dependency "railties", ">= 4.2"
18
+
19
+ s.add_development_dependency "bundler", "~> 1.12"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- test/*`.split("\n")
23
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webpacker_lite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - David Heinemeier Hansson, Justin Gordon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '4.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '4.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ description:
70
+ email: justin@shakacode.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".gitignore"
76
+ - ".rubocop.yml"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - MIT-LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - lib/install/config/webpack/development.server.yml
84
+ - lib/install/config/webpack/paths.yml
85
+ - lib/install/template.rb
86
+ - lib/tasks/webpacker.rake
87
+ - lib/tasks/webpacker_lite/check_node.rake
88
+ - lib/tasks/webpacker_lite/check_yarn.rake
89
+ - lib/tasks/webpacker_lite/install.rake
90
+ - lib/tasks/webpacker_lite/verify_install.rake
91
+ - lib/webpacker-lite.rb
92
+ - lib/webpacker_lite/configuration.rb
93
+ - lib/webpacker_lite/env.rb
94
+ - lib/webpacker_lite/file_loader.rb
95
+ - lib/webpacker_lite/helper.rb
96
+ - lib/webpacker_lite/manifest.rb
97
+ - lib/webpacker_lite/railtie.rb
98
+ - lib/webpacker_lite/version.rb
99
+ - webpacker.gemspec
100
+ homepage: https://github.com/shakacode/webpacker_lite
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.9.3
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.6.8
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Asset Helpers for Webpack
124
+ test_files: []