webpack_on_rails 0.1.0
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +171 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/webpack_on_rails/example_generator.rb +25 -0
- data/lib/generators/webpack_on_rails/install_generator.rb +76 -0
- data/lib/generators/webpack_on_rails/templates/app/controllers/webpacks_controller.rb +5 -0
- data/lib/generators/webpack_on_rails/templates/app/views/layouts/webpacks.html.erb +13 -0
- data/lib/generators/webpack_on_rails/templates/app/views/webpacks/index.html.erb +1 -0
- data/lib/generators/webpack_on_rails/templates/client/config/development.js +15 -0
- data/lib/generators/webpack_on_rails/templates/client/config/loaders/babel.js +7 -0
- data/lib/generators/webpack_on_rails/templates/client/config/loaders/css.js +12 -0
- data/lib/generators/webpack_on_rails/templates/client/config/loaders/extract-text-sass.js +22 -0
- data/lib/generators/webpack_on_rails/templates/client/config/loaders/font.js +4 -0
- data/lib/generators/webpack_on_rails/templates/client/config/loaders/sass.js +7 -0
- data/lib/generators/webpack_on_rails/templates/client/config/plugins/extract-text-css.js +3 -0
- data/lib/generators/webpack_on_rails/templates/client/config/production.js +44 -0
- data/lib/generators/webpack_on_rails/templates/client/config/server.development.js +37 -0
- data/lib/generators/webpack_on_rails/templates/client/config/shared.js +42 -0
- data/lib/generators/webpack_on_rails/templates/client/entries/webpack-application/index.js +10 -0
- data/lib/generators/webpack_on_rails/templates/client/entries/webpack-application/index.js.empty +0 -0
- data/lib/generators/webpack_on_rails/templates/client/entries/webpack-application/index.scss +10 -0
- data/lib/generators/webpack_on_rails/templates/client/entries/webpack-application/variables.scss +4 -0
- data/lib/generators/webpack_on_rails/templates/client/package.json +42 -0
- data/lib/webpack_on_rails.rb +5 -0
- data/lib/webpack_on_rails/version.rb +3 -0
- data/webpack_on_rails.gemspec +28 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d9e77b1827096320d84c5c62ad309f28998b6775
|
4
|
+
data.tar.gz: ea9394cd100d24e43150d15c6f105fca7f67e161
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f192ba4108a4081b1f2a4bbae78de401688124c1f42735357e44e74a4aec513185cc94727fb6ea3af0c384c742abf61e64722f47895aa2440e64920be02d4867
|
7
|
+
data.tar.gz: 8b497e6f607d3c1e543d337bc4af500259a2dcea8f27410671d2c85a88752b6c9b600c942b2580030b95fd4cad2acf7b4a5bbcd3df0d5bc22d74a970673b195a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Alex Kwiatkowski
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
# WebpackOnRails
|
2
|
+
|
3
|
+
Use the full power of Webpack within your Rails app, leverage existing view
|
4
|
+
helpers like `javascript_include_tag` & `stylesheet_link_tag`
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'webpack_on_rails'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install webpack_on_rails
|
21
|
+
|
22
|
+
Run the install generator to create the Webpack configuration files and an empty
|
23
|
+
Webpack entry
|
24
|
+
|
25
|
+
```
|
26
|
+
rails g webpack_on_rails:install
|
27
|
+
```
|
28
|
+
|
29
|
+
Which creates the directory structure:
|
30
|
+
|
31
|
+
+ `client/`
|
32
|
+
- `config/`
|
33
|
+
+ `...`
|
34
|
+
+ `entries/`
|
35
|
+
+ `webpack-application`
|
36
|
+
+ `index.js`
|
37
|
+
- `lib/`
|
38
|
+
- `package.json`
|
39
|
+
|
40
|
+
Install the node packages via:
|
41
|
+
|
42
|
+
### yarn
|
43
|
+
|
44
|
+
```
|
45
|
+
cd client && yarn
|
46
|
+
```
|
47
|
+
|
48
|
+
or
|
49
|
+
|
50
|
+
### npm
|
51
|
+
|
52
|
+
```
|
53
|
+
cd client && npm install
|
54
|
+
```
|
55
|
+
|
56
|
+
## Rails Template Usage
|
57
|
+
|
58
|
+
Reference your Webpack entry bundles using the standard Rails helpers
|
59
|
+
|
60
|
+
```erb
|
61
|
+
<% # app/views/layouts/application.html.erb %>
|
62
|
+
<!DOCTYPE html>
|
63
|
+
<html lang="en">
|
64
|
+
<head>
|
65
|
+
<%= stylesheet_link_tag "webpack-application", media: :all %>
|
66
|
+
</head>
|
67
|
+
<body>
|
68
|
+
<%= yield %>
|
69
|
+
|
70
|
+
<%= javascript_include_tag "webpack-application" %>
|
71
|
+
</body>
|
72
|
+
</html>
|
73
|
+
```
|
74
|
+
|
75
|
+
## Usage
|
76
|
+
|
77
|
+
In development you can run Webpack in 2 modes:
|
78
|
+
|
79
|
+
* `watch` - Recompiles on change, writes to disk, page refresh required to view changes
|
80
|
+
* `devserver` - Recompiles on change, doesn't write files to disk, can automatically reload your changes
|
81
|
+
|
82
|
+
### watch
|
83
|
+
|
84
|
+
Run the build task and allow the build to finish. This will generate the manifest
|
85
|
+
file that sprockets uses to map logical paths `webpack-application.js` to file
|
86
|
+
system paths `webpack-application-8f88619b6ef3a358a7ad.js` and write the build artifacts
|
87
|
+
to `public/assets`.
|
88
|
+
|
89
|
+
```
|
90
|
+
cd client && yarn run build:dev
|
91
|
+
```
|
92
|
+
|
93
|
+
Once the manifest has been generated start a Rails server.
|
94
|
+
|
95
|
+
```
|
96
|
+
rails s
|
97
|
+
```
|
98
|
+
|
99
|
+
Unfortunately sprockets doesn't currently support automatic reloading of the manifest
|
100
|
+
file when it changes. If you add or rename any bundles you will need to `spring stop`
|
101
|
+
and restart the Rails server. If sprockets (or one of us :)) adds support for manifest
|
102
|
+
reloading we would be able to enable asset fingerprints in development. Thus getting us
|
103
|
+
closer to replicating a production environment as we develop.
|
104
|
+
|
105
|
+
### devserver
|
106
|
+
|
107
|
+
Devserver can provide a faster and more efficient development workflow by hot
|
108
|
+
reloading modules as they are recompiled.
|
109
|
+
|
110
|
+
Run the server task and allow the build to finish. This will generate the manifest
|
111
|
+
file that sprockets uses to map logical paths `webpack-application.js` to file
|
112
|
+
system paths `webpack-application-8f88619b6ef3a358a7ad.js`. Devserver writes the build
|
113
|
+
artifacts to memory and serves them up via a node http server on `http://localhost:8080`
|
114
|
+
|
115
|
+
```
|
116
|
+
cd client && yarn run server
|
117
|
+
```
|
118
|
+
|
119
|
+
Once the manifest has been generated start a Rails server and set the `ASSET_HOST` environment
|
120
|
+
variable to the devserver address.
|
121
|
+
|
122
|
+
```
|
123
|
+
ASSET_HOST=http://localhost:8080 rails s
|
124
|
+
```
|
125
|
+
|
126
|
+
## Foreman & Invoker
|
127
|
+
|
128
|
+
If you would like to manage your processes in 1 command and load environment variables from a
|
129
|
+
file, take a look at the [foreman](https://github.com/theforeman/foreman) or [invoker](https://github.com/code-mancers/invoker) gems.
|
130
|
+
|
131
|
+
## Heroku
|
132
|
+
|
133
|
+
Follow the [instructions](https://devcenter.heroku.com/articles/nodejs-support)
|
134
|
+
to install the ruby and node multi-buildpack.
|
135
|
+
|
136
|
+
Create a `package.json` file in the root of the rails project.
|
137
|
+
|
138
|
+
```json
|
139
|
+
{
|
140
|
+
"name": "MyProject",
|
141
|
+
"version": "1.0.0",
|
142
|
+
"description": "A description of MyProject",
|
143
|
+
"main": "index.js",
|
144
|
+
"cacheDirectories": [
|
145
|
+
"client/node_modules"
|
146
|
+
],
|
147
|
+
"scripts": {
|
148
|
+
"preinstall": "cd client && npm install",
|
149
|
+
"postinstall": "cd client && npm run build"
|
150
|
+
}
|
151
|
+
}
|
152
|
+
```
|
153
|
+
|
154
|
+
## How Does It Work?
|
155
|
+
|
156
|
+
[webpack-sprockets-rails-manifest-plugin](https://github.com/rupurt/webpack-sprockets-rails-manifest-plugin#how-does-it-work)
|
157
|
+
has a full description of the Webpack plugin
|
158
|
+
|
159
|
+
## Development
|
160
|
+
|
161
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
162
|
+
|
163
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
164
|
+
|
165
|
+
## Contributing
|
166
|
+
|
167
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rupurt/webpack_on_rails.
|
168
|
+
|
169
|
+
## License
|
170
|
+
|
171
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "webpack_on_rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module WebpackOnRails
|
4
|
+
module Generators
|
5
|
+
class ExampleGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
def create_webpack_application_entry
|
9
|
+
empty_directory "client/entries/webpack-application"
|
10
|
+
|
11
|
+
template "client/entries/webpack-application/index.js", "client/entries/webpack-application/index.js"
|
12
|
+
template "client/entries/webpack-application/index.scss", "client/entries/webpack-application/index.scss"
|
13
|
+
template "client/entries/webpack-application/variables.scss", "client/entries/webpack-application/variables.scss"
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_webpack_application_scaffold
|
17
|
+
template "app/controllers/webpacks_controller.rb", "app/controllers/webpacks_controller.rb"
|
18
|
+
template "app/views/layouts/webpacks.html.erb", "app/views/layouts/webpacks.html.erb"
|
19
|
+
template "app/views/webpacks/index.html.erb", "app/views/webpacks/index.html.erb"
|
20
|
+
|
21
|
+
route "resources :webpacks, only: :index"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module WebpackOnRails
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
def create_client_dirs
|
9
|
+
empty_directory "client"
|
10
|
+
empty_directory "client/config"
|
11
|
+
empty_directory "client/config/loaders"
|
12
|
+
empty_directory "client/config/plugins"
|
13
|
+
empty_directory "client/entries"
|
14
|
+
empty_directory "client/lib"
|
15
|
+
|
16
|
+
create_file "client/lib/.gitkeep"
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_package_json
|
20
|
+
template "client/package.json", "client/package.json"
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_configs
|
24
|
+
template "client/config/shared.js", "client/config/shared.js"
|
25
|
+
template "client/config/development.js", "client/config/development.js"
|
26
|
+
template "client/config/server.development.js", "client/config/server.development.js"
|
27
|
+
template "client/config/production.js", "client/config/production.js"
|
28
|
+
|
29
|
+
template "client/config/loaders/babel.js", "client/config/loaders/babel.js"
|
30
|
+
template "client/config/loaders/font.js", "client/config/loaders/font.js"
|
31
|
+
template "client/config/loaders/css.js", "client/config/loaders/css.js"
|
32
|
+
template "client/config/loaders/sass.js", "client/config/loaders/sass.js"
|
33
|
+
template "client/config/loaders/extract-text-sass.js", "client/config/loaders/extract-text-sass.js"
|
34
|
+
|
35
|
+
template "client/config/plugins/extract-text-css.js", "client/config/plugins/extract-text-css.js"
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_empty_webpack_application
|
39
|
+
empty_directory "client/entries/webpack-application"
|
40
|
+
|
41
|
+
template "client/entries/webpack-application/index.js.empty", "client/entries/webpack-application/index.js"
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_asset_manifest_location
|
45
|
+
append_to_file "config/initializers/assets.rb" do
|
46
|
+
<<-ASSET_MANIFEST.strip_heredoc
|
47
|
+
|
48
|
+
# Avoid creating the manifest file in public/assets as it can be downloaded by anyone
|
49
|
+
Rails.configuration.assets.manifest = Rails.root.join("config", "sprockets-manifest.json")
|
50
|
+
ASSET_MANIFEST
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def disable_asset_debug
|
55
|
+
gsub_file \
|
56
|
+
"config/environments/development.rb",
|
57
|
+
/config\.assets\.debug\s*=\s*\w+$/,
|
58
|
+
"config.assets.debug = false"
|
59
|
+
end
|
60
|
+
|
61
|
+
def replace_asset_host
|
62
|
+
inject_into_class \
|
63
|
+
"config/application.rb",
|
64
|
+
"Application",
|
65
|
+
<<-ASSET_HOST
|
66
|
+
if ENV["ASSET_HOST"].present?
|
67
|
+
Rails.application.config.action_controller.asset_host = proc { |source, _request|
|
68
|
+
ENV["ASSET_HOST"]
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
ASSET_HOST
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<p class="loading">Loading webpack-application...</p>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const webpack = require("webpack");
|
2
|
+
const extractTextCssPlugin = require("./plugins/extract-text-css");
|
3
|
+
const sprocketsRailsManifestPlugin = require("./plugins/sprockets-rails-manifest.js");
|
4
|
+
const extractTextSassLoader = require("./loaders/extract-text-sass");
|
5
|
+
const config = require("./shared");
|
6
|
+
|
7
|
+
config.plugins.unshift(extractTextCssPlugin);
|
8
|
+
|
9
|
+
config.plugins = config.plugins.push(sprocketsRailsManifestPlugin);
|
10
|
+
|
11
|
+
config.module.rules.push(extractTextSassLoader);
|
12
|
+
|
13
|
+
config.devtool = "inline-eval-cheap-source-map";
|
14
|
+
|
15
|
+
module.exports = config;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
test: /\.scss$/,
|
5
|
+
use: ExtractTextPlugin.extract({
|
6
|
+
fallback: "style-loader",
|
7
|
+
use: [
|
8
|
+
{
|
9
|
+
loader: "css-loader",
|
10
|
+
options: {
|
11
|
+
modules: true
|
12
|
+
}
|
13
|
+
},
|
14
|
+
{
|
15
|
+
loader: "sass-loader",
|
16
|
+
options: {
|
17
|
+
modules: true
|
18
|
+
}
|
19
|
+
}
|
20
|
+
]
|
21
|
+
})
|
22
|
+
};
|
@@ -0,0 +1,44 @@
|
|
1
|
+
const webpack = require("webpack");
|
2
|
+
const config = require("./shared");
|
3
|
+
const CompressionPlugin = require("compression-webpack-plugin");
|
4
|
+
const sprocketsRailsManifestPlugin = require("./plugins/sprockets-rails-manifest.js");
|
5
|
+
const extractTextCssPlugin = require("./plugins/extract-text-css");
|
6
|
+
const extractTextSassLoader = require("./loaders/extract-text-sass");
|
7
|
+
|
8
|
+
config.output.filename = "[name]-[chunkhash].js";
|
9
|
+
|
10
|
+
config.plugins.unshift(
|
11
|
+
extractTextCssPlugin
|
12
|
+
);
|
13
|
+
config.plugins.unshift(
|
14
|
+
new webpack.DefinePlugin({
|
15
|
+
"process.env": {
|
16
|
+
NODE_ENV: JSON.stringify("production")
|
17
|
+
}
|
18
|
+
})
|
19
|
+
);
|
20
|
+
|
21
|
+
config.plugins = config.plugins.concat([
|
22
|
+
extractTextCssPlugin,
|
23
|
+
|
24
|
+
new webpack.optimize.UglifyJsPlugin({
|
25
|
+
compress: {
|
26
|
+
warnings: false
|
27
|
+
},
|
28
|
+
mangle: false
|
29
|
+
}),
|
30
|
+
|
31
|
+
new CompressionPlugin({
|
32
|
+
asset: "[path].gz[query]",
|
33
|
+
algorithm: "gzip",
|
34
|
+
test: /\.js$/,
|
35
|
+
threshold: 10240,
|
36
|
+
minRatio: 0.8
|
37
|
+
}),
|
38
|
+
|
39
|
+
sprocketsRailsManifestPlugin
|
40
|
+
]);
|
41
|
+
|
42
|
+
config.module.rules.push(extractTextSassLoader);
|
43
|
+
|
44
|
+
module.exports = config;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
const webpack = require("webpack");
|
2
|
+
const config = require("./shared");
|
3
|
+
const sassLoader = require("./loaders/sass");
|
4
|
+
|
5
|
+
config.output.publicPath = "http://localhost:8080/assets/";
|
6
|
+
|
7
|
+
function devServerEntries() {
|
8
|
+
var entry = {};
|
9
|
+
|
10
|
+
Object.keys(config.entry).forEach((key) => {
|
11
|
+
var existing = config.entry[key];
|
12
|
+
var entries = (existing instanceof Array) ? existing.slice() : Array.of(existing);
|
13
|
+
|
14
|
+
entry[key] = entries.concat([
|
15
|
+
"webpack-dev-server/client?http://localhost:8080",
|
16
|
+
"webpack/hot/only-dev-server"
|
17
|
+
]);
|
18
|
+
});
|
19
|
+
|
20
|
+
return entry;
|
21
|
+
}
|
22
|
+
config.entry = devServerEntries();
|
23
|
+
|
24
|
+
config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
|
25
|
+
|
26
|
+
config.module.rules.push(sassLoader);
|
27
|
+
|
28
|
+
config.devServer = {
|
29
|
+
contentBase: config.output.path,
|
30
|
+
publicPath: config.output.publicPath,
|
31
|
+
hot: true,
|
32
|
+
inline: true
|
33
|
+
};
|
34
|
+
|
35
|
+
config.devtool = "inline-eval-cheap-source-map";
|
36
|
+
|
37
|
+
module.exports = config;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
const path = require("path");
|
2
|
+
const WebpackSprocketsRailsManifestPlugin = require("webpack-sprockets-rails-manifest-plugin");
|
3
|
+
const babelLoader = require("./loaders/babel");
|
4
|
+
const fontLoader = require("./loaders/font");
|
5
|
+
const cssLoader = require("./loaders/css");
|
6
|
+
|
7
|
+
const config = {
|
8
|
+
context: path.resolve(__dirname, ".."),
|
9
|
+
|
10
|
+
entry: {
|
11
|
+
"webpack-application": "./entries/webpack-application/index.js"
|
12
|
+
},
|
13
|
+
|
14
|
+
output: {
|
15
|
+
path: path.resolve(__dirname, "../../public/assets"),
|
16
|
+
filename: "[name].js"
|
17
|
+
},
|
18
|
+
|
19
|
+
resolve: {
|
20
|
+
modules: [
|
21
|
+
path.resolve(__dirname, "../node_modules")
|
22
|
+
]
|
23
|
+
},
|
24
|
+
|
25
|
+
plugins: [
|
26
|
+
new WebpackSprocketsRailsManifestPlugin()
|
27
|
+
],
|
28
|
+
|
29
|
+
resolve: {
|
30
|
+
extensions: [".jsx", ".js", ".json"]
|
31
|
+
},
|
32
|
+
|
33
|
+
module: {
|
34
|
+
rules: [
|
35
|
+
babelLoader,
|
36
|
+
fontLoader,
|
37
|
+
cssLoader
|
38
|
+
]
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
module.exports = config;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import indexStyle from "./index.scss";
|
2
|
+
|
3
|
+
const main = document.createElement("div");
|
4
|
+
main.innerText = "Hi, I'm a Webpack application!";
|
5
|
+
main.className = indexStyle.webpackApplication;
|
6
|
+
|
7
|
+
document.body.appendChild(main);
|
8
|
+
|
9
|
+
const loading = document.querySelector(".loading");
|
10
|
+
loading.style.display = "none";
|
data/lib/generators/webpack_on_rails/templates/client/entries/webpack-application/index.js.empty
ADDED
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"name": "client",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Client assets",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"build": "NODE_ENV=production webpack --config ./config/production.js",
|
8
|
+
"build:dev": "webpack --config ./config/development.js --watch",
|
9
|
+
"server": "webpack-dev-server --config ./config/server.development.js"
|
10
|
+
},
|
11
|
+
"repository": {
|
12
|
+
"type": "git",
|
13
|
+
"url": "git+https://github.com/rupurt/webpack_on_rails.git"
|
14
|
+
},
|
15
|
+
"keywords": [
|
16
|
+
"webpack",
|
17
|
+
"rails"
|
18
|
+
],
|
19
|
+
"author": "You",
|
20
|
+
"license": "MIT",
|
21
|
+
"bugs": {
|
22
|
+
"url": "https://github.com/rupurt/webpack_on_rails/issues"
|
23
|
+
},
|
24
|
+
"homepage": "https://github.com/rupurt/webpack_on_rails#readme",
|
25
|
+
"dependencies": {
|
26
|
+
"babel-core": "^6.22.1",
|
27
|
+
"babel-loader": "^6.2.10",
|
28
|
+
"babel-polyfill": "^6.22.0",
|
29
|
+
"babel-preset-latest": "^6.22.0",
|
30
|
+
"babel-preset-react": "^6.22.0",
|
31
|
+
"compression-webpack-plugin": "^0.3.2",
|
32
|
+
"css-loader": "^0.26.1",
|
33
|
+
"extract-text-webpack-plugin": "^2.0.0",
|
34
|
+
"node-sass": "^4.5.0",
|
35
|
+
"sass-loader": "^6.0.1",
|
36
|
+
"style-loader": "^0.13.1",
|
37
|
+
"webpack": "^2.2.1",
|
38
|
+
"webpack-dev-server": "^2.3.0",
|
39
|
+
"webpack-sprockets-rails-manifest-plugin": "^0.0.4"
|
40
|
+
},
|
41
|
+
"devDependencies": {}
|
42
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'webpack_on_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "webpack_on_rails"
|
8
|
+
spec.version = WebpackOnRails::VERSION
|
9
|
+
spec.authors = ["Alex Kwiatkowski"]
|
10
|
+
spec.email = ["alex+git@rival-studios.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Use the full power of Webpack within your Rails app}
|
13
|
+
spec.description = %q{Use the full power of Webpack within your Rails app, leverage existing view helpers like javascript_include_tag & stylesheet_link_tag}
|
14
|
+
spec.homepage = "https://github.com/rupurt/webpack_on_rails"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "rails", ">= 4.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webpack_on_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Kwiatkowski
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
description: Use the full power of Webpack within your Rails app, leverage existing
|
70
|
+
view helpers like javascript_include_tag & stylesheet_link_tag
|
71
|
+
email:
|
72
|
+
- alex+git@rival-studios.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- lib/generators/webpack_on_rails/example_generator.rb
|
87
|
+
- lib/generators/webpack_on_rails/install_generator.rb
|
88
|
+
- lib/generators/webpack_on_rails/templates/app/controllers/webpacks_controller.rb
|
89
|
+
- lib/generators/webpack_on_rails/templates/app/views/layouts/webpacks.html.erb
|
90
|
+
- lib/generators/webpack_on_rails/templates/app/views/webpacks/index.html.erb
|
91
|
+
- lib/generators/webpack_on_rails/templates/client/config/development.js
|
92
|
+
- lib/generators/webpack_on_rails/templates/client/config/loaders/babel.js
|
93
|
+
- lib/generators/webpack_on_rails/templates/client/config/loaders/css.js
|
94
|
+
- lib/generators/webpack_on_rails/templates/client/config/loaders/extract-text-sass.js
|
95
|
+
- lib/generators/webpack_on_rails/templates/client/config/loaders/font.js
|
96
|
+
- lib/generators/webpack_on_rails/templates/client/config/loaders/sass.js
|
97
|
+
- lib/generators/webpack_on_rails/templates/client/config/plugins/extract-text-css.js
|
98
|
+
- lib/generators/webpack_on_rails/templates/client/config/production.js
|
99
|
+
- lib/generators/webpack_on_rails/templates/client/config/server.development.js
|
100
|
+
- lib/generators/webpack_on_rails/templates/client/config/shared.js
|
101
|
+
- lib/generators/webpack_on_rails/templates/client/entries/webpack-application/index.js
|
102
|
+
- lib/generators/webpack_on_rails/templates/client/entries/webpack-application/index.js.empty
|
103
|
+
- lib/generators/webpack_on_rails/templates/client/entries/webpack-application/index.scss
|
104
|
+
- lib/generators/webpack_on_rails/templates/client/entries/webpack-application/variables.scss
|
105
|
+
- lib/generators/webpack_on_rails/templates/client/package.json
|
106
|
+
- lib/webpack_on_rails.rb
|
107
|
+
- lib/webpack_on_rails/version.rb
|
108
|
+
- webpack_on_rails.gemspec
|
109
|
+
homepage: https://github.com/rupurt/webpack_on_rails
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.6.10
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Use the full power of Webpack within your Rails app
|
133
|
+
test_files: []
|