sprockets-webpack 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 694c7fac7f7516d6377db228c84b0830d3abae0a
4
- data.tar.gz: daba8af0d8350e1dbc421c8414f6fb2031ddaed0
3
+ metadata.gz: 72010deee64fbb7419489eadb1c842f840dfdf0d
4
+ data.tar.gz: 4ff0ea23977b58d0f14b735d47a2885a560e8214
5
5
  SHA512:
6
- metadata.gz: f2ba3589031ce16074b1e121234073cdae3434baf911f91113643e55d8432545ef0756b6da4bfa43cd6a30a2029dfab0bc64cc3de78b88240a883e293557109e
7
- data.tar.gz: 441972622d8e6a2fcf0231246fd89a871594a596867a5e22d4e8971c6c6739dd1f7e6405a6dae2c0539e84c507fa7952e4a1d91fca8aead83aa53fdbdb3ec11a
6
+ metadata.gz: f081ea2bd71c431a5b549d722b4ab8e5ddb2bbbe4d11533e34b46e33521e81a72115e6d89e9f8cc003e9b29fbf45c6ee5a57657c9ec1a4b469d79e84e4b277d0
7
+ data.tar.gz: 7d1bb2c81453c9284dd26c42e9daced46d97eff78f96ddad973f35e228e5c3d0b50d392b857d494ff5412ce33a9e661c8901522f5dae2f487e6b5c4153c70d1d
@@ -9,7 +9,6 @@ module Webpack
9
9
  def create_barebone_file
10
10
  template 'config/webpack.config.js'
11
11
  template 'package.json'
12
- template '.slugignore'
13
12
  end
14
13
 
15
14
  def create_sample_assets
@@ -25,7 +24,15 @@ module Webpack
25
24
 
26
25
  def adjust_gitignore
27
26
  if File.exist?('.gitignore')
28
- append_to_file '.gitignore', "\n/node_modules\n"
27
+ append_to_file '.gitignore', "\nnode_modules\n"
28
+ end
29
+ end
30
+
31
+ def adjust_slugignore
32
+ if File.exist?('.slugignore')
33
+ append_to_file '.slugignore', "\nnode_modules\n"
34
+ else
35
+ create_file '.slugignore', "node_modules\n"
29
36
  end
30
37
  end
31
38
 
@@ -0,0 +1,6 @@
1
+ // Here you can use ES6 "import" syntax
2
+ // Just remember to install the corresponding NPM package ;)
3
+
4
+ // import React from 'react';
5
+
6
+ window.alert("Find me in app/assets/webpack/index.js");
@@ -0,0 +1,24 @@
1
+ // Your package.json should include related packages
2
+ // Remember to run npm install before starting Rails app
3
+ var config = {
4
+ module: {
5
+ loaders: [
6
+ {
7
+ test: /\.jsx?$/,
8
+ exclude: /(node_modules|bower_components)/,
9
+ loader: 'babel',
10
+ query: {
11
+ presets: ['es2015', 'react']
12
+ }
13
+ }
14
+ ]
15
+ }
16
+ };
17
+
18
+ // if NODE_ENV not set, it defaults to Rails.env (for Rails apps) or ENV['RACK_ENV'].
19
+ // Otherwise it's always "development"
20
+ if (process.env.NODE_ENV == 'development') {
21
+ config.devtool = '#eval-source-map';
22
+ }
23
+
24
+ module.exports = config;
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "<%= Rails.application.railtie_name %>",
3
+ "version": "1.0.0",
4
+ "description": "Rails webpack bundle",
5
+ "directories": { },
6
+ "dependencies": { },
7
+ "private": true,
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 0"
10
+ },
11
+ "author": "",
12
+ "license": "ISC"
13
+ }
@@ -0,0 +1,54 @@
1
+ var webpack = require("webpack");
2
+ var readline = require('readline');
3
+ var configFullPath = require.resolve(process.argv[2]);
4
+
5
+ const rl = readline.createInterface({
6
+ input: process.stdin,
7
+ output: process.stdout,
8
+ terminal: false
9
+ });
10
+
11
+ function prepareConfig() {
12
+ delete require.cache[configFullPath];
13
+ var config = require(configFullPath);
14
+ config.entry = process.argv[3];
15
+ config.output = {
16
+ path: process.argv[4],
17
+ filename: process.argv[5]
18
+ };
19
+ return webpack(config);
20
+ }
21
+
22
+ var compiler = prepareConfig();
23
+
24
+ rl.on('line', function(line) {
25
+ if (line.trim() == 'RELOAD') {
26
+ compiler = prepareConfig();
27
+ }
28
+
29
+ compiler.run(function(err, stats) {
30
+ if (err) {
31
+ console.log("FATAL", err);
32
+ }
33
+
34
+ var jsonStats = stats.toJson();
35
+
36
+ if (jsonStats.errors.length > 0) {
37
+ console.log("WEBPACK ERRORS");
38
+ printArray(jsonStats.errors);
39
+ }
40
+
41
+ if (jsonStats.warnings.length > 0) {
42
+ console.log("WEBPACK WARNINGS");
43
+ printArray(jsonStats.warnings);
44
+ }
45
+
46
+ console.log("WEBPACK::EOF");
47
+ });
48
+ });
49
+
50
+ function printArray(arr) {
51
+ arr.forEach(function(item) {
52
+ console.log(item);
53
+ });
54
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-webpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Yartsev
@@ -59,7 +59,11 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
61
  - lib/generators/webpack/install/install_generator.rb
62
+ - lib/generators/webpack/install/templates/app/assets/webpack/index.js
63
+ - lib/generators/webpack/install/templates/config/webpack.config.js
64
+ - lib/generators/webpack/install/templates/package.json
62
65
  - lib/sprockets/webpack.rb
66
+ - lib/sprockets/webpack/compiler.js
63
67
  - lib/sprockets/webpack/file_guard.rb
64
68
  - lib/sprockets/webpack/webpack_directive_processor.rb
65
69
  - lib/sprockets/webpack/webpack_driver.rb