webpacker 1.0 → 1.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.
- checksums.yaml +4 -4
- data/.eslintrc.js +14 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +124 -0
- data/.travis.yml +24 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -6
- data/README.md +126 -19
- data/lib/install/angular.rb +18 -0
- data/lib/install/bin/webpack-dev-server.tt +23 -12
- data/lib/install/bin/webpack-watcher.tt +3 -0
- data/lib/install/bin/webpack.tt +33 -7
- data/lib/install/config/.postcssrc.yml +4 -0
- data/lib/install/config/loaders/core/assets.js +12 -0
- data/lib/install/config/loaders/core/babel.js +10 -0
- data/lib/install/config/loaders/core/coffee.js +4 -0
- data/lib/install/config/loaders/core/erb.js +9 -0
- data/lib/install/config/loaders/core/sass.js +9 -0
- data/lib/install/config/loaders/installers/angular.js +4 -0
- data/lib/install/config/loaders/installers/react.js +11 -0
- data/lib/install/config/loaders/installers/vue.js +10 -0
- data/lib/install/config/webpack/configuration.js +21 -0
- data/lib/install/config/webpack/development.js +16 -0
- data/lib/install/config/webpack/development.server.js +17 -0
- data/lib/install/config/webpack/development.server.yml +4 -0
- data/lib/install/config/webpack/paths.yml +19 -0
- data/lib/install/config/webpack/production.js +20 -0
- data/lib/install/config/webpack/shared.js +51 -0
- data/lib/install/{angular → examples/angular}/hello_angular.js +1 -1
- data/lib/install/{angular → examples/angular}/hello_angular/app/app.component.ts +0 -0
- data/lib/install/{angular → examples/angular}/hello_angular/app/app.module.ts +0 -0
- data/lib/install/{angular → examples/angular}/hello_angular/index.ts +0 -0
- data/lib/install/{angular → examples/angular}/hello_angular/polyfills.ts +0 -0
- data/lib/install/{angular → examples/angular}/tsconfig.json +0 -0
- data/lib/install/examples/react/.babelrc +3 -0
- data/lib/install/examples/react/hello_react.jsx +25 -0
- data/lib/install/examples/vue/app.vue +22 -0
- data/lib/install/examples/vue/hello_vue.js +19 -0
- data/lib/install/javascript/packs/application.js +1 -0
- data/lib/install/react.rb +15 -0
- data/lib/install/template.rb +20 -14
- data/lib/install/vue.rb +15 -0
- data/lib/tasks/installers.rake +21 -0
- data/lib/tasks/webpacker.rake +14 -107
- data/lib/tasks/webpacker/compile.rake +29 -0
- data/lib/tasks/webpacker/install.rake +12 -0
- data/lib/tasks/webpacker/verify_install.rake +16 -0
- data/lib/tasks/webpacker/yarn_install.rake +6 -0
- data/lib/webpacker.rb +1 -1
- data/lib/webpacker/configuration.rb +42 -0
- data/lib/webpacker/file_loader.rb +24 -0
- data/lib/webpacker/helper.rb +32 -3
- data/lib/webpacker/manifest.rb +29 -0
- data/lib/webpacker/railtie.rb +6 -16
- data/lib/webpacker/version.rb +3 -0
- data/package.json +28 -0
- data/webpacker.gemspec +15 -12
- data/yarn.lock +1014 -0
- metadata +50 -20
- data/lib/install/config/development.js +0 -24
- data/lib/install/config/production.js +0 -16
- data/lib/install/config/shared.js +0 -70
- data/lib/install/react/.babelrc +0 -3
- data/lib/install/react/hello_react.js +0 -16
- data/lib/webpacker/digests.rb +0 -42
- data/lib/webpacker/source.rb +0 -38
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: multi_json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,36 +72,66 @@ executables: []
|
|
72
72
|
extensions: []
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
|
+
- ".eslintrc.js"
|
75
76
|
- ".gitignore"
|
77
|
+
- ".rubocop.yml"
|
78
|
+
- ".travis.yml"
|
76
79
|
- Gemfile
|
77
80
|
- Gemfile.lock
|
78
81
|
- MIT-LICENSE
|
79
82
|
- README.md
|
80
83
|
- Rakefile
|
81
|
-
- lib/install/angular
|
82
|
-
- lib/install/angular/hello_angular/app/app.component.ts
|
83
|
-
- lib/install/angular/hello_angular/app/app.module.ts
|
84
|
-
- lib/install/angular/hello_angular/index.ts
|
85
|
-
- lib/install/angular/hello_angular/polyfills.ts
|
86
|
-
- lib/install/angular/tsconfig.json
|
84
|
+
- lib/install/angular.rb
|
87
85
|
- lib/install/bin/webpack-dev-server.tt
|
88
86
|
- lib/install/bin/webpack-watcher.tt
|
89
87
|
- lib/install/bin/webpack.tt
|
90
88
|
- lib/install/bin/yarn.tt
|
91
|
-
- lib/install/config
|
92
|
-
- lib/install/config/
|
93
|
-
- lib/install/config/
|
89
|
+
- lib/install/config/.postcssrc.yml
|
90
|
+
- lib/install/config/loaders/core/assets.js
|
91
|
+
- lib/install/config/loaders/core/babel.js
|
92
|
+
- lib/install/config/loaders/core/coffee.js
|
93
|
+
- lib/install/config/loaders/core/erb.js
|
94
|
+
- lib/install/config/loaders/core/sass.js
|
95
|
+
- lib/install/config/loaders/installers/angular.js
|
96
|
+
- lib/install/config/loaders/installers/react.js
|
97
|
+
- lib/install/config/loaders/installers/vue.js
|
98
|
+
- lib/install/config/webpack/configuration.js
|
99
|
+
- lib/install/config/webpack/development.js
|
100
|
+
- lib/install/config/webpack/development.server.js
|
101
|
+
- lib/install/config/webpack/development.server.yml
|
102
|
+
- lib/install/config/webpack/paths.yml
|
103
|
+
- lib/install/config/webpack/production.js
|
104
|
+
- lib/install/config/webpack/shared.js
|
105
|
+
- lib/install/examples/angular/hello_angular.js
|
106
|
+
- lib/install/examples/angular/hello_angular/app/app.component.ts
|
107
|
+
- lib/install/examples/angular/hello_angular/app/app.module.ts
|
108
|
+
- lib/install/examples/angular/hello_angular/index.ts
|
109
|
+
- lib/install/examples/angular/hello_angular/polyfills.ts
|
110
|
+
- lib/install/examples/angular/tsconfig.json
|
111
|
+
- lib/install/examples/react/.babelrc
|
112
|
+
- lib/install/examples/react/hello_react.jsx
|
113
|
+
- lib/install/examples/vue/app.vue
|
114
|
+
- lib/install/examples/vue/hello_vue.js
|
94
115
|
- lib/install/javascript/packs/application.js
|
95
|
-
- lib/install/react
|
96
|
-
- lib/install/react/hello_react.js
|
116
|
+
- lib/install/react.rb
|
97
117
|
- lib/install/template.rb
|
118
|
+
- lib/install/vue.rb
|
119
|
+
- lib/tasks/installers.rake
|
98
120
|
- lib/tasks/webpacker.rake
|
121
|
+
- lib/tasks/webpacker/compile.rake
|
122
|
+
- lib/tasks/webpacker/install.rake
|
123
|
+
- lib/tasks/webpacker/verify_install.rake
|
124
|
+
- lib/tasks/webpacker/yarn_install.rake
|
99
125
|
- lib/webpacker.rb
|
100
|
-
- lib/webpacker/
|
126
|
+
- lib/webpacker/configuration.rb
|
127
|
+
- lib/webpacker/file_loader.rb
|
101
128
|
- lib/webpacker/helper.rb
|
129
|
+
- lib/webpacker/manifest.rb
|
102
130
|
- lib/webpacker/railtie.rb
|
103
|
-
- lib/webpacker/
|
131
|
+
- lib/webpacker/version.rb
|
132
|
+
- package.json
|
104
133
|
- webpacker.gemspec
|
134
|
+
- yarn.lock
|
105
135
|
homepage: https://github.com/rails/webpacker
|
106
136
|
licenses:
|
107
137
|
- MIT
|
@@ -122,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
152
|
version: '0'
|
123
153
|
requirements: []
|
124
154
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.6.
|
155
|
+
rubygems_version: 2.6.8
|
126
156
|
signing_key:
|
127
157
|
specification_version: 4
|
128
158
|
summary: Use Webpack to manage app-like JavaScript modules in Rails
|
@@ -1,24 +0,0 @@
|
|
1
|
-
// Note: You must restart bin/webpack-watcher for changes to take effect
|
2
|
-
|
3
|
-
var webpack = require('webpack')
|
4
|
-
var merge = require('webpack-merge')
|
5
|
-
|
6
|
-
var sharedConfig = require('./shared.js')
|
7
|
-
|
8
|
-
module.exports = merge(sharedConfig.config, {
|
9
|
-
devtool: 'sourcemap',
|
10
|
-
|
11
|
-
stats: {
|
12
|
-
errorDetails: true
|
13
|
-
},
|
14
|
-
|
15
|
-
output: {
|
16
|
-
pathinfo: true
|
17
|
-
},
|
18
|
-
|
19
|
-
plugins: [
|
20
|
-
new webpack.LoaderOptionsPlugin({
|
21
|
-
debug: true
|
22
|
-
})
|
23
|
-
]
|
24
|
-
})
|
@@ -1,16 +0,0 @@
|
|
1
|
-
// Note: You must restart bin/webpack-watcher for changes to take effect
|
2
|
-
|
3
|
-
var webpack = require('webpack')
|
4
|
-
var merge = require('webpack-merge')
|
5
|
-
|
6
|
-
var sharedConfig = require('./shared.js')
|
7
|
-
|
8
|
-
module.exports = merge(sharedConfig.config, {
|
9
|
-
output: { filename: '[name]-[hash].js' },
|
10
|
-
|
11
|
-
plugins: [
|
12
|
-
new webpack.LoaderOptionsPlugin({
|
13
|
-
minimize: true
|
14
|
-
})
|
15
|
-
]
|
16
|
-
})
|
@@ -1,70 +0,0 @@
|
|
1
|
-
// Note: You must restart bin/webpack-watcher for changes to take effect
|
2
|
-
|
3
|
-
var webpack = require('webpack')
|
4
|
-
var path = require('path')
|
5
|
-
var process = require('process')
|
6
|
-
var glob = require('glob')
|
7
|
-
var extname = require('path-complete-extname')
|
8
|
-
var distDir = process.env.WEBPACK_DIST_DIR
|
9
|
-
|
10
|
-
if(distDir === undefined) {
|
11
|
-
distDir = 'packs'
|
12
|
-
}
|
13
|
-
|
14
|
-
config = {
|
15
|
-
entry: glob.sync(path.join('app', 'javascript', 'packs', '*.js*')).reduce(
|
16
|
-
function(map, entry) {
|
17
|
-
var basename = path.basename(entry, extname(entry))
|
18
|
-
map[basename] = path.resolve(entry)
|
19
|
-
return map
|
20
|
-
}, {}
|
21
|
-
),
|
22
|
-
|
23
|
-
output: { filename: '[name].js', path: path.resolve('public', distDir) },
|
24
|
-
|
25
|
-
module: {
|
26
|
-
rules: [
|
27
|
-
{ test: /\.coffee(.erb)?$/, loader: "coffee-loader" },
|
28
|
-
{
|
29
|
-
test: /\.js(.erb)?$/,
|
30
|
-
exclude: /node_modules/,
|
31
|
-
loader: 'babel-loader',
|
32
|
-
options: {
|
33
|
-
presets: [
|
34
|
-
[ 'latest', { 'es2015': { 'modules': false } } ]
|
35
|
-
]
|
36
|
-
}
|
37
|
-
},
|
38
|
-
{
|
39
|
-
test: /.erb$/,
|
40
|
-
enforce: 'pre',
|
41
|
-
exclude: /node_modules/,
|
42
|
-
loader: 'rails-erb-loader',
|
43
|
-
options: {
|
44
|
-
runner: 'DISABLE_SPRING=1 bin/rails runner'
|
45
|
-
}
|
46
|
-
},
|
47
|
-
]
|
48
|
-
},
|
49
|
-
|
50
|
-
plugins: [
|
51
|
-
new webpack.EnvironmentPlugin(Object.keys(process.env))
|
52
|
-
],
|
53
|
-
|
54
|
-
resolve: {
|
55
|
-
extensions: [ '.js', '.coffee' ],
|
56
|
-
modules: [
|
57
|
-
path.resolve('app/javascript'),
|
58
|
-
path.resolve('node_modules')
|
59
|
-
]
|
60
|
-
},
|
61
|
-
|
62
|
-
resolveLoader: {
|
63
|
-
modules: [ path.resolve('node_modules') ]
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
module.exports = {
|
68
|
-
distDir: distDir,
|
69
|
-
config: config
|
70
|
-
}
|
data/lib/install/react/.babelrc
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
// Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
|
2
|
-
// like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom
|
3
|
-
// of the page.
|
4
|
-
|
5
|
-
import React from 'react'
|
6
|
-
import ReactDOM from 'react-dom'
|
7
|
-
|
8
|
-
class Hello extends React.Component {
|
9
|
-
render() {
|
10
|
-
return <div>Hello {this.props.name}!</div>
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
document.addEventListener("DOMContentLoaded", e => {
|
15
|
-
ReactDOM.render(<Hello name="React" />, document.body.appendChild(document.createElement('div')))
|
16
|
-
})
|
data/lib/webpacker/digests.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# Singleton registry for accessing the digested filenames computed by Webpack in production mode.
|
2
|
-
# This allows javascript_pack_tag to take a reference to, say, "calendar.js" and turn it into
|
3
|
-
# "calendar-1016838bab065ae1e314.js". These digested filenames are what enables you to long-term
|
4
|
-
# cache things in production.
|
5
|
-
class Webpacker::Digests
|
6
|
-
class DigestError < StandardError; end
|
7
|
-
|
8
|
-
class_attribute :instance
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def load(path)
|
12
|
-
self.instance = new(path)
|
13
|
-
end
|
14
|
-
|
15
|
-
def lookup(name)
|
16
|
-
if instance
|
17
|
-
instance.lookup(name).presence || raise(DigestError.new("Can't find #{name} in #{instance.inspect}"))
|
18
|
-
else
|
19
|
-
raise DigestError.new("Webpacker::Digests.load(path) must be called first")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def initialize(path)
|
25
|
-
@path = path
|
26
|
-
@digests = load
|
27
|
-
end
|
28
|
-
|
29
|
-
def lookup(name)
|
30
|
-
@digests[name.to_s]
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
def load
|
35
|
-
if File.exist?(@path)
|
36
|
-
JSON.parse(File.read(@path))
|
37
|
-
else
|
38
|
-
Rails.logger.info "Didn't find any digests file at #{@path}. You must first compile the packs via rails webpacker:compile"
|
39
|
-
{}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/webpacker/source.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Translates a logical reference for a pack source into the final path needed in the HTML.
|
2
|
-
# This translation takes into account whether digesting is configured to happen, which it
|
3
|
-
# is by default in the production environment (as set via
|
4
|
-
# `Rails.configuration.x.webpacker[:digesting] = true`).
|
5
|
-
class Webpacker::Source
|
6
|
-
def initialize(name)
|
7
|
-
@name = name
|
8
|
-
end
|
9
|
-
|
10
|
-
def path
|
11
|
-
if config[:dev_server_host].present?
|
12
|
-
"#{config[:dev_server_host]}/#{filename}"
|
13
|
-
elsif config[:digesting]
|
14
|
-
File.join(dist_path, digested_filename)
|
15
|
-
else
|
16
|
-
File.join(dist_path, filename)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
attr_accessor :name
|
22
|
-
|
23
|
-
def config
|
24
|
-
Rails.configuration.x.webpacker
|
25
|
-
end
|
26
|
-
|
27
|
-
def digested_filename
|
28
|
-
Webpacker::Digests.lookup(name)
|
29
|
-
end
|
30
|
-
|
31
|
-
def dist_path
|
32
|
-
config[:packs_dist_path]
|
33
|
-
end
|
34
|
-
|
35
|
-
def filename
|
36
|
-
"#{name}.js"
|
37
|
-
end
|
38
|
-
end
|