middleman-webpacked 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9c6871016b63c750529f7050aef41c01652fe011
4
+ data.tar.gz: 95b3c3e2b0ec9a83d78cdf435a356c26c9b792a8
5
+ SHA512:
6
+ metadata.gz: 4010c42165f9a037890d7d4b9b44bf29979d9b4a46a10d86c1a6bb0c9e9afabc329bb3f9af837b3567dd8f7c23d9196d9fa70e7001eead92e814313759210dbf
7
+ data.tar.gz: 0fc5b4352f633a13e53c47625509c15b1c62c06e3529865e41621b0ea14421c7b0763322cc8720c83f09d37303475cb92d0c8c13981332f85402c4b6f47987e8
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in middleman-webpack.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem 'rake'
10
+ gem 'rdoc'
11
+ gem 'yard'
12
+ end
13
+
14
+ group :test do
15
+ gem 'capybara'
16
+ gem 'cucumber'
17
+ gem 'aruba'
18
+ gem 'rspec'
19
+ end
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ Middleman Webpack
2
+ ===
3
+
4
+ ## Usage
5
+
6
+ Add this line to your `Gemfile`
7
+
8
+ ```ruby
9
+ gem 'middleman-webpacked', '~> 0.0.2'
10
+ ```
11
+
12
+ Setup your Webpack
13
+
14
+ ```ruby
15
+ middleman webpack
16
+ ```
17
+
18
+ Add `javascript_pack_tag` to your layout
19
+
20
+ ```erb
21
+ <%= javascript_pack_tag 'bundle' %>
22
+ ```
23
+
24
+ Activate the extension in `config.rb`
25
+
26
+ ```ruby
27
+ activate :webpack
28
+ ```
29
+
30
+ Put the javascript into `src` directory
31
+
32
+ > This version only support Webpack 4 default config
33
+
34
+ ## Options
35
+
36
+ ### Entry
37
+
38
+ If you want to output more than one file (`bundle.js`) you can specify the entry options.
39
+
40
+ ```ruby
41
+ activate :webpack,
42
+ entry: {
43
+ app: 'index.js',
44
+ ext: 'ext.js'
45
+ }
46
+ ```
47
+
48
+ ## Roadmap
49
+
50
+ * [x] Running Webpack without config
51
+ * [ ] Automatic setup `webpack.config.js`
52
+ * [x] Babel Support
53
+ * [ ] React.js Support
54
+ * [ ] Vue.js Support
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ t.cucumber_opts = '--color --tags --strict'
8
+ end
9
+
10
+ require 'rake/clean'
11
+
12
+ task test: ['cucumber']
13
+
14
+ task default: :test
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-webpack')
@@ -0,0 +1,18 @@
1
+ require 'middleman-core/cli'
2
+
3
+ module Middleman
4
+ module Cli
5
+ class Webpack < ::Thor::Group
6
+ include Thor::Actions
7
+
8
+ check_unknown_options!
9
+
10
+ def webpack
11
+ run 'yarn add webpack webpack-dev-server webpack-cli babel-loader --dev'
12
+ end
13
+
14
+ # Add to CLI
15
+ Base.register( self, 'webpack', 'webpack [options]', 'Install webpack to middleman')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,59 @@
1
+ # Require core library
2
+ require 'middleman-core'
3
+
4
+ # Extension namespace
5
+ module Middleman
6
+ class WebpackedExtension < ::Middleman::Extension
7
+ option :source, '.webpack-cache', 'The webpack dist path'
8
+ option :entry, {bundle: 'index.js'}, 'The entry points(s) of the compilation'
9
+
10
+ WEBPACK_DEV_SERVER_BIN = 'node_modules/.bin/webpack-dev-server'
11
+ WEBPACK_BIN = 'node_modules/.bin/webpack'
12
+
13
+ def initialize(app, options_hash={}, &block)
14
+ super
15
+
16
+ fail 'Webpack Dev Server not found' unless File.exists?(WEBPACK_DEV_SERVER_BIN)
17
+ fail 'Webpack not found' unless File.exist?(WEBPACK_BIN)
18
+ end
19
+
20
+ def after_configuration
21
+ active_webpack
22
+ end
23
+
24
+ def active_webpack
25
+ app.activate :external_pipeline,
26
+ name: :webpack,
27
+ command: command,
28
+ source: options.source,
29
+ latency: 1
30
+ end
31
+
32
+ def command
33
+ return build_command if app.build?
34
+ "#{WEBPACK_DEV_SERVER_BIN} --mode development " \
35
+ '--module-bind js=babel-loader ' \
36
+ '--hot --progress --color --inline --content-base source ' \
37
+ "#{options.entry.map { |name, path| "--entry #{name}=./src/#{path}" }.join(' ')} " \
38
+ "--output-public-path /#{app.config[:js_dir]} "
39
+ end
40
+
41
+ def build_command
42
+ "#{WEBPACK_BIN} --mode production " \
43
+ '--module-bind js=babel-loader ' \
44
+ "#{options.entry.map { |name, path| "--entry #{name}=./src/#{path}" }.join(' ')} " \
45
+ "--bail -p --output-path #{options.source}/#{app.config[:js_dir]}"
46
+ end
47
+
48
+ def after_build
49
+ FileUtils.rm_rf(options.source)
50
+ end
51
+
52
+ helpers do
53
+ def javascript_pack_tag(name)
54
+ return javascript_include_tag "#{app.config[:js_dir]}/#{name}" if app.build?
55
+ javascript_include_tag "http://localhost:8080/#{app.config[:js_dir]}/#{name}.js"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module MiddlemanWebpacked
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,8 @@
1
+ require "middleman-core"
2
+
3
+ Middleman::Extensions.register :webpack do
4
+ require "middleman-webpacked/commands/webpack"
5
+ require "middleman-webpacked/extension"
6
+
7
+ Middleman::WebpackedExtension
8
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'middleman-webpacked/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "middleman-webpacked"
7
+ s.version = MiddlemanWebpacked::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Aotokitsuruya"]
10
+ s.email = ["contact@frost.tw"]
11
+ s.homepage = "https://github.com/elct9620/middleman-webpacked"
12
+ s.summary = %q{Enable webpack for your middleman project eaiser}
13
+ s.description = %q{Enable webpack for your middleman project eaiser}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # The version of middleman-core your extension depends on
21
+ s.add_runtime_dependency("middleman-core", [">= 4.2.1"])
22
+
23
+ # Additional dependencies
24
+ # s.add_runtime_dependency("gem-name", "gem-version")
25
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-webpacked
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Aotokitsuruya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.1
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.1
27
+ description: Enable webpack for your middleman project eaiser
28
+ email:
29
+ - contact@frost.tw
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - README.md
37
+ - Rakefile
38
+ - features/support/env.rb
39
+ - lib/middleman-webpacked.rb
40
+ - lib/middleman-webpacked/commands/webpack.rb
41
+ - lib/middleman-webpacked/extension.rb
42
+ - lib/middleman-webpacked/version.rb
43
+ - middleman-webpacked.gemspec
44
+ homepage: https://github.com/elct9620/middleman-webpacked
45
+ licenses: []
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.6.14
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Enable webpack for your middleman project eaiser
67
+ test_files:
68
+ - features/support/env.rb