webpack_rails 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webpack_rails/engine.rb +6 -0
- data/lib/webpack_rails/processor.rb +1 -1
- data/lib/webpack_rails/task.rb +12 -0
- data/lib/webpack_rails/webpack-task.js +5 -4
- data/lib/webpack_rails/webpack.rake +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddb9eeee4bbff9584582e6b7c92e4a654e2a9af8
|
4
|
+
data.tar.gz: f12e3aceb14f4a508f49fef60caca7b2e54f8ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b93a1aa955ebe77fa38091d5c6b895d4cca14a287ee941a4ac540ce9633099f53376be84cdff4b14576b07d6294bac3e4b95742f9b6a57c15988d78022b9248
|
7
|
+
data.tar.gz: c9bf05d74228ddcac831458a5b1166c44dd7dfdd08a9656c925b22742c3ceee85bd91a922f4d33abe22d7edd02ac0249d9307d76a019e7a2216169622917e5a0
|
data/lib/webpack_rails/engine.rb
CHANGED
@@ -2,11 +2,17 @@ require_relative './processor'
|
|
2
2
|
|
3
3
|
module WebpackRails
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
+
engine_name "webpack"
|
6
|
+
|
5
7
|
initializer :setup_webpack_rails, :after => "sprockets.environment", :group => :all do |app|
|
6
8
|
# where [name].bundle.js files should be
|
7
9
|
app.assets.append_path Rails.root.join('tmp/webpack/bundles')
|
8
10
|
# process
|
9
11
|
app.assets.register_preprocessor('application/javascript', WebpackRails::Processor)
|
10
12
|
end
|
13
|
+
|
14
|
+
rake_tasks do
|
15
|
+
load 'webpack_rails/webpack.rake'
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
data/lib/webpack_rails/task.rb
CHANGED
@@ -47,14 +47,26 @@ module WebpackRails
|
|
47
47
|
return_value
|
48
48
|
end
|
49
49
|
|
50
|
+
def build_result
|
51
|
+
begin
|
52
|
+
JSON.parse(File.open(File.join(working_dir, 'webpack-build-result.json')).read)
|
53
|
+
rescue Errno::ENOENT => e
|
54
|
+
{modules: []}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
50
58
|
def run_webpack(opts = nil)
|
51
59
|
result = nil
|
60
|
+
if ENV['DISABLE_WEBPACK']
|
61
|
+
return build_result
|
62
|
+
end
|
52
63
|
|
53
64
|
task_duration = Benchmark.realtime do
|
54
65
|
result = with_app_node_path do
|
55
66
|
begin
|
56
67
|
task = self.new
|
57
68
|
task.run(opts)
|
69
|
+
build_result
|
58
70
|
rescue NodeTask::Error => e
|
59
71
|
raise self::Error.new(e)
|
60
72
|
end
|
@@ -2,9 +2,10 @@ var webpack = require('webpack');
|
|
2
2
|
var fs = require('fs');
|
3
3
|
var path = require('path');
|
4
4
|
|
5
|
-
var
|
5
|
+
var stdoutLogging = process.env.WEBPACK_STDOUT_LOGGING;
|
6
|
+
var loggingToFile = true;
|
6
7
|
function log(message) {
|
7
|
-
if (
|
8
|
+
if (loggingToFile) fs.appendFile('log/webpack-task.log', message+'\n');
|
8
9
|
}
|
9
10
|
|
10
11
|
// TODO: add support for multiple builds using multiple webpack configs which
|
@@ -21,6 +22,8 @@ var lastBuildResult = null;
|
|
21
22
|
function buildComplete(buildResult) {
|
22
23
|
lastBuildResult = buildResult;
|
23
24
|
|
25
|
+
if (stdoutLogging) console.log('rebuild complete');
|
26
|
+
|
24
27
|
currentBuildCallbacks.forEach(function(callback) {
|
25
28
|
log('async completion callback');
|
26
29
|
callback(buildResult);
|
@@ -77,8 +80,6 @@ module.exports = function waitForBuild(opts, done) {
|
|
77
80
|
else done(null, buildResult);
|
78
81
|
}
|
79
82
|
|
80
|
-
log('watcher.running: '+JSON.stringify(watcher.running));
|
81
|
-
|
82
83
|
if (!watcher.running) {
|
83
84
|
sendResults(lastBuildResult);
|
84
85
|
} else {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative './task'
|
2
|
+
|
3
|
+
namespace :webpack do
|
4
|
+
task :watch do
|
5
|
+
puts 'watching for webpack changes'
|
6
|
+
WebpackRails::Task.with_app_node_path do
|
7
|
+
system "WEBPACK_STDOUT_LOGGING=yes #{WebpackRails::Task.node_command} #{WebpackRails::Task.webpack_task_script}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
task :before_assets_precompile do
|
12
|
+
# with production config, sprockets index isn't updated correctly by the
|
13
|
+
# find_asset monkey patch. instead, we just run it before precompiling assets
|
14
|
+
WebpackRails::Task.run_webpack
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# runs before every 'rake assets:precompile'
|
19
|
+
Rake::Task['assets:precompile'].enhance(['webpack:before_assets_precompile'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpack_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Friend
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: node_task
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/webpack_rails/sprockets_index_webpack.rb
|
58
58
|
- lib/webpack_rails/task.rb
|
59
59
|
- lib/webpack_rails/webpack-task.js
|
60
|
+
- lib/webpack_rails/webpack.rake
|
60
61
|
homepage: https://rubygems.org/gems/webpack_rails
|
61
62
|
licenses:
|
62
63
|
- MIT
|