webpacker_ejector 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +146 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/webpacker_ejector/eject_generator.rb +61 -0
- data/lib/generators/webpacker_ejector/templates/webpack.config.js.erb +188 -0
- data/lib/generators/webpacker_ejector/templates/webpacker.yml +8 -0
- data/lib/webpacker_ejector.rb +4 -0
- data/lib/webpacker_ejector/version.rb +3 -0
- data/webpacker_ejector.gemspec +31 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2e44670775f5fa12b19ad2adc567ec9f97d55cfcfe5a3c7103d834e834fcba88
|
4
|
+
data.tar.gz: eb4c6dbac89a09f05fd8d10cff917cd5662c483219c94ae3b4a697a6ee95c5f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c4857dbcbaa32c1a2c2f7c792ac56503202baeb3f58a1ffbabd8a5da19e825fe5e5ce72fea0e27773355ed87bab67c9a602e3e3595d3cb5f5754d287ba94d018
|
7
|
+
data.tar.gz: f6a930252a24f3f5188e06aaa774d101e06d3590130439749456ad65cfeb1ad59dad87359399fd31230f08e8719e5a5f985d81773b3fb31b149b9e4d7ddb1b46
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ameutau@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
webpacker_ejector (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (6.0.0.beta3)
|
10
|
+
actionpack (= 6.0.0.beta3)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (>= 0.6.1)
|
13
|
+
actionmailbox (6.0.0.beta3)
|
14
|
+
actionpack (= 6.0.0.beta3)
|
15
|
+
activejob (= 6.0.0.beta3)
|
16
|
+
activerecord (= 6.0.0.beta3)
|
17
|
+
activestorage (= 6.0.0.beta3)
|
18
|
+
activesupport (= 6.0.0.beta3)
|
19
|
+
mail (>= 2.7.1)
|
20
|
+
actionmailer (6.0.0.beta3)
|
21
|
+
actionpack (= 6.0.0.beta3)
|
22
|
+
actionview (= 6.0.0.beta3)
|
23
|
+
activejob (= 6.0.0.beta3)
|
24
|
+
mail (~> 2.5, >= 2.5.4)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
actionpack (6.0.0.beta3)
|
27
|
+
actionview (= 6.0.0.beta3)
|
28
|
+
activesupport (= 6.0.0.beta3)
|
29
|
+
rack (~> 2.0)
|
30
|
+
rack-test (>= 0.6.3)
|
31
|
+
rails-dom-testing (~> 2.0)
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
33
|
+
actiontext (6.0.0.beta3)
|
34
|
+
actionpack (= 6.0.0.beta3)
|
35
|
+
activerecord (= 6.0.0.beta3)
|
36
|
+
activestorage (= 6.0.0.beta3)
|
37
|
+
activesupport (= 6.0.0.beta3)
|
38
|
+
nokogiri (>= 1.8.5)
|
39
|
+
actionview (6.0.0.beta3)
|
40
|
+
activesupport (= 6.0.0.beta3)
|
41
|
+
builder (~> 3.1)
|
42
|
+
erubi (~> 1.4)
|
43
|
+
rails-dom-testing (~> 2.0)
|
44
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
45
|
+
activejob (6.0.0.beta3)
|
46
|
+
activesupport (= 6.0.0.beta3)
|
47
|
+
globalid (>= 0.3.6)
|
48
|
+
activemodel (6.0.0.beta3)
|
49
|
+
activesupport (= 6.0.0.beta3)
|
50
|
+
activerecord (6.0.0.beta3)
|
51
|
+
activemodel (= 6.0.0.beta3)
|
52
|
+
activesupport (= 6.0.0.beta3)
|
53
|
+
activestorage (6.0.0.beta3)
|
54
|
+
actionpack (= 6.0.0.beta3)
|
55
|
+
activerecord (= 6.0.0.beta3)
|
56
|
+
marcel (~> 0.3.1)
|
57
|
+
activesupport (6.0.0.beta3)
|
58
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
59
|
+
i18n (>= 0.7, < 2)
|
60
|
+
minitest (~> 5.1)
|
61
|
+
tzinfo (~> 1.1)
|
62
|
+
zeitwerk (~> 1.3, >= 1.3.1)
|
63
|
+
builder (3.2.3)
|
64
|
+
concurrent-ruby (1.1.5)
|
65
|
+
crass (1.0.4)
|
66
|
+
erubi (1.8.0)
|
67
|
+
globalid (0.4.2)
|
68
|
+
activesupport (>= 4.2.0)
|
69
|
+
i18n (1.6.0)
|
70
|
+
concurrent-ruby (~> 1.0)
|
71
|
+
loofah (2.2.3)
|
72
|
+
crass (~> 1.0.2)
|
73
|
+
nokogiri (>= 1.5.9)
|
74
|
+
mail (2.7.1)
|
75
|
+
mini_mime (>= 0.1.1)
|
76
|
+
marcel (0.3.3)
|
77
|
+
mimemagic (~> 0.3.2)
|
78
|
+
method_source (0.9.2)
|
79
|
+
mimemagic (0.3.3)
|
80
|
+
mini_mime (1.0.1)
|
81
|
+
mini_portile2 (2.4.0)
|
82
|
+
minitest (5.8.5)
|
83
|
+
minitest-hooks (1.5.0)
|
84
|
+
minitest (> 5.3)
|
85
|
+
nio4r (2.3.1)
|
86
|
+
nokogiri (1.10.1)
|
87
|
+
mini_portile2 (~> 2.4.0)
|
88
|
+
rack (2.0.6)
|
89
|
+
rack-test (1.1.0)
|
90
|
+
rack (>= 1.0, < 3)
|
91
|
+
rails (6.0.0.beta3)
|
92
|
+
actioncable (= 6.0.0.beta3)
|
93
|
+
actionmailbox (= 6.0.0.beta3)
|
94
|
+
actionmailer (= 6.0.0.beta3)
|
95
|
+
actionpack (= 6.0.0.beta3)
|
96
|
+
actiontext (= 6.0.0.beta3)
|
97
|
+
actionview (= 6.0.0.beta3)
|
98
|
+
activejob (= 6.0.0.beta3)
|
99
|
+
activemodel (= 6.0.0.beta3)
|
100
|
+
activerecord (= 6.0.0.beta3)
|
101
|
+
activestorage (= 6.0.0.beta3)
|
102
|
+
activesupport (= 6.0.0.beta3)
|
103
|
+
bundler (>= 1.3.0)
|
104
|
+
railties (= 6.0.0.beta3)
|
105
|
+
sprockets-rails (>= 2.0.0)
|
106
|
+
rails-dom-testing (2.0.3)
|
107
|
+
activesupport (>= 4.2.0)
|
108
|
+
nokogiri (>= 1.6)
|
109
|
+
rails-html-sanitizer (1.0.4)
|
110
|
+
loofah (~> 2.2, >= 2.2.2)
|
111
|
+
railties (6.0.0.beta3)
|
112
|
+
actionpack (= 6.0.0.beta3)
|
113
|
+
activesupport (= 6.0.0.beta3)
|
114
|
+
method_source
|
115
|
+
rake (>= 0.8.7)
|
116
|
+
thor (>= 0.20.3, < 2.0)
|
117
|
+
rake (10.5.0)
|
118
|
+
sprockets (3.7.2)
|
119
|
+
concurrent-ruby (~> 1.0)
|
120
|
+
rack (> 1, < 3)
|
121
|
+
sprockets-rails (3.2.1)
|
122
|
+
actionpack (>= 4.0)
|
123
|
+
activesupport (>= 4.0)
|
124
|
+
sprockets (>= 3.0.0)
|
125
|
+
thor (0.20.3)
|
126
|
+
thread_safe (0.3.6)
|
127
|
+
tzinfo (1.2.5)
|
128
|
+
thread_safe (~> 0.1)
|
129
|
+
websocket-driver (0.7.0)
|
130
|
+
websocket-extensions (>= 0.1.0)
|
131
|
+
websocket-extensions (0.1.3)
|
132
|
+
zeitwerk (1.3.4)
|
133
|
+
|
134
|
+
PLATFORMS
|
135
|
+
ruby
|
136
|
+
|
137
|
+
DEPENDENCIES
|
138
|
+
bundler (~> 2.0)
|
139
|
+
minitest (~> 5.8.4)
|
140
|
+
minitest-hooks (~> 1.5.0)
|
141
|
+
rails (~> 6.0.0.beta3)
|
142
|
+
rake (~> 10.0)
|
143
|
+
webpacker_ejector!
|
144
|
+
|
145
|
+
BUNDLED WITH
|
146
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Kohei Hasegawa
|
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,42 @@
|
|
1
|
+
# webpacker_ejector
|
2
|
+
|
3
|
+
A generator to eject webpack from Rails.
|
4
|
+
|
5
|
+
Tried to add this feature into webpacker on [this](https://github.com/rails/webpacker/pull/1916) but it's difficult to be merged as following reasons.
|
6
|
+
|
7
|
+
* Due to current implementation of webapcker, generate webpack config dynamically is not available.
|
8
|
+
* Double maintenance template and webpacker's code is hard.
|
9
|
+
|
10
|
+
So I've extracted as generator for now.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'webpacker_ejector'
|
18
|
+
```
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```
|
23
|
+
bundle exec rails generate webpacker_ejector:eject
|
24
|
+
```
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
|
30
|
+
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).
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/webpacker_ejector. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
39
|
+
|
40
|
+
## Code of Conduct
|
41
|
+
|
42
|
+
Everyone interacting in the WebpackerEjector project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/webpacker_ejector/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "webpacker_ejector"
|
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,61 @@
|
|
1
|
+
module WebpackerEjector
|
2
|
+
module Generators
|
3
|
+
class EjectGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('templates', __dir__)
|
5
|
+
|
6
|
+
def generate_webpack_config
|
7
|
+
loaders = Dir.glob("#{Rails.root.join('config/webpack/loaders')}/*")
|
8
|
+
.map { |loader|
|
9
|
+
basename = File.basename(loader, File.extname(loader))
|
10
|
+
"require('./loaders/#{basename}')"
|
11
|
+
}
|
12
|
+
webpacker_config = YAML.load_file(Rails.root.join('config/webpacker.yml'))
|
13
|
+
say 'Copying webpack.config.js'
|
14
|
+
File.write(Rails.root.join('config/webpack/webpack.config.js'), ERB.new(File.read("#{__dir__}/templates/webpack.config.js.erb"), nil, '-').result(binding))
|
15
|
+
end
|
16
|
+
|
17
|
+
def install_dependencies
|
18
|
+
say "Installing all dependencies"
|
19
|
+
|
20
|
+
dependencies = %w[
|
21
|
+
webpack
|
22
|
+
webpack-cli
|
23
|
+
mini-css-extract-plugin
|
24
|
+
webpack-assets-manifest
|
25
|
+
case-sensitive-paths-webpack-plugin
|
26
|
+
pnp-webpack-plugin
|
27
|
+
babel-loader
|
28
|
+
]
|
29
|
+
|
30
|
+
run "yarn add #{dependencies.join(' ')}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def inject_npm_run_scripts
|
34
|
+
scripts = %Q(\n "start": "webpack --progress --watch --config config/webpack/webpack.config.js",\n "build": "NODE_ENV=production webpack --progress --config config/webpack/webpack.config.js")
|
35
|
+
npm_scripts = %Q("scripts": {#{scripts}\n },\n )
|
36
|
+
|
37
|
+
if File.foreach(Rails.root.join('package.json')).grep(/"scripts":\s+{/).any?
|
38
|
+
insert_into_file Rails.root.join("package.json").to_s, "#{scripts},", after: /"scripts":\s+{/
|
39
|
+
else
|
40
|
+
insert_into_file Rails.root.join("package.json").to_s, npm_scripts, before: /"dependencies":\s+{/
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def replace_webpacker_yml
|
45
|
+
remove_file "#{Rails.root.join('config/webpacker.yml')}"
|
46
|
+
copy_file "#{__dir__}/templates/webpacker.yml", "#{Rails.root.join('config/webpacker.yml')}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def remove_files
|
50
|
+
remove_file "#{Rails.root.join('config/webpack/development.js')}"
|
51
|
+
remove_file "#{Rails.root.join('config/webpack/test.js')}"
|
52
|
+
remove_file "#{Rails.root.join('config/webpack/production.js')}"
|
53
|
+
remove_file "#{Rails.root.join('config/webpack/environment.js')}"
|
54
|
+
remove_file "#{Rails.root.join('bin/webpack')}"
|
55
|
+
remove_file "#{Rails.root.join('bin/webpack-dev-server')}"
|
56
|
+
|
57
|
+
say "Webpacker successfully ejected 🎉 🍰", :green
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
<%- config = webpacker_config['development'] -%>
|
2
|
+
const glob = require('glob');
|
3
|
+
const path = require('path');
|
4
|
+
const webpack = require('webpack');
|
5
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
6
|
+
const WebpackAssetsManifest = require('webpack-assets-manifest')
|
7
|
+
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
|
8
|
+
const PnpWebpackPlugin = require('pnp-webpack-plugin')
|
9
|
+
|
10
|
+
const packs = path.join(__dirname, '..', '..', 'app', 'javascript', 'packs');
|
11
|
+
const targets = glob.sync(path.join(packs, '**/*.{js,jsx,ts,tsx}'))
|
12
|
+
|
13
|
+
const nodeEnv = process.env.NODE_ENV || 'development';
|
14
|
+
|
15
|
+
const inDevServer = process.argv.find(v => v.includes('webpack-dev-server'))
|
16
|
+
const isHMR = inDevServer && (devServer && devServer.hmr)
|
17
|
+
|
18
|
+
const styleLoader = {
|
19
|
+
loader: 'style-loader',
|
20
|
+
options: {
|
21
|
+
hmr: isHMR,
|
22
|
+
sourceMap: true
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
const getStyleRule = (test, modules = false, preprocessors = []) => {
|
27
|
+
const use = [
|
28
|
+
{
|
29
|
+
loader: 'css-loader',
|
30
|
+
options: {
|
31
|
+
sourceMap: true,
|
32
|
+
importLoaders: 2,
|
33
|
+
localIdentName: '[name]__[local]___[hash:base64:5]',
|
34
|
+
modules
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
loader: 'postcss-loader',
|
39
|
+
options: {
|
40
|
+
config: { path: path.resolve() },
|
41
|
+
sourceMap: true
|
42
|
+
}
|
43
|
+
},
|
44
|
+
...preprocessors
|
45
|
+
]
|
46
|
+
|
47
|
+
const options = modules ? { include: /\.module\.[a-z]+$/ } : { exclude: /\.module\.[a-z]+$/ }
|
48
|
+
|
49
|
+
if (nodeEnv === 'production') {
|
50
|
+
use.unshift(MiniCssExtractPlugin.loader)
|
51
|
+
} else {
|
52
|
+
use.unshift(styleLoader)
|
53
|
+
}
|
54
|
+
|
55
|
+
// sideEffects - See https://github.com/webpack/webpack/issues/6571
|
56
|
+
return {
|
57
|
+
...{ test, use, sideEffects: !modules },
|
58
|
+
...options,
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
const entry = targets.reduce((acc, target) => {
|
63
|
+
const bundle = path.relative(packs, target)
|
64
|
+
const ext = path.extname(bundle)
|
65
|
+
return {
|
66
|
+
...acc,
|
67
|
+
...{ [bundle.replace(ext, '')]: './app/javascript/packs/' + bundle },
|
68
|
+
}
|
69
|
+
}, {})
|
70
|
+
|
71
|
+
module.exports = {
|
72
|
+
mode: nodeEnv === "development" ? 'development' : 'production',
|
73
|
+
entry,
|
74
|
+
output: {
|
75
|
+
filename: '[name]-[chunkhash].js',
|
76
|
+
chunkFilename: '[name]-[chunkhash].chunk.js',
|
77
|
+
hotUpdateChunkFilename: '[id]-[hash].hot-update.js',
|
78
|
+
path: path.join(__dirname, '..', '..', 'public', 'packs'),
|
79
|
+
publicPath: '/packs/',
|
80
|
+
pathinfo: true
|
81
|
+
},
|
82
|
+
resolve: {
|
83
|
+
extensions: <%= config['extensions'] %>,
|
84
|
+
plugins: [PnpWebpackPlugin],
|
85
|
+
modules: [
|
86
|
+
path.resolve('<%= config['source_path'] %>'),
|
87
|
+
<%- config['resolved_paths'].each do |path| -%>
|
88
|
+
path.resolve('<%= path %>'),
|
89
|
+
<%- end -%>
|
90
|
+
'node_modules',
|
91
|
+
]
|
92
|
+
},
|
93
|
+
cache: true,
|
94
|
+
devtool: 'cheap-module-source-map',
|
95
|
+
devServer: <%= config['dev_server'].to_json %>,
|
96
|
+
module: {
|
97
|
+
strictExportPresence: true,
|
98
|
+
rules: [
|
99
|
+
{ parser: { requireEnsure: false } },
|
100
|
+
{
|
101
|
+
test: new RegExp(/<%= config['static_assets_extensions'].join('|') %>/, 'i'),
|
102
|
+
use: [
|
103
|
+
{
|
104
|
+
loader: 'file-loader',
|
105
|
+
options: {
|
106
|
+
name: '[path][name]-[hash].[ext]',
|
107
|
+
context: path.join('<%= config['source_path'] %>')
|
108
|
+
}
|
109
|
+
}
|
110
|
+
]
|
111
|
+
},
|
112
|
+
{
|
113
|
+
test: /\.(js|jsx|mjs)?(\.erb)?$/,
|
114
|
+
include: path.resolve('<%= config['source_path'] %>'),
|
115
|
+
exclude: /node_modules/,
|
116
|
+
use: [
|
117
|
+
{
|
118
|
+
loader: 'babel-loader',
|
119
|
+
options: {
|
120
|
+
cacheDirectory: path.join('<%= config['cache_path'] %>', 'babel-loader-node-modules'),
|
121
|
+
cacheCompression: nodeEnv === 'production',
|
122
|
+
compact: nodeEnv === 'production'
|
123
|
+
}
|
124
|
+
}
|
125
|
+
]
|
126
|
+
},
|
127
|
+
{
|
128
|
+
test: /\.(js|mjs)$/,
|
129
|
+
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
130
|
+
use: [
|
131
|
+
{
|
132
|
+
loader: 'babel-loader',
|
133
|
+
options: {
|
134
|
+
babelrc: false,
|
135
|
+
presets: [['@babel/preset-env', { modules: false }]],
|
136
|
+
cacheDirectory: path.join('<%= config['cache_path'] %>', 'babel-loader-node-modules'),
|
137
|
+
cacheCompression: nodeEnv === 'production',
|
138
|
+
compact: false,
|
139
|
+
sourceMaps: false
|
140
|
+
}
|
141
|
+
}
|
142
|
+
]
|
143
|
+
},
|
144
|
+
getStyleRule(/\.(css)$/i),
|
145
|
+
getStyleRule(/\.(css)$/i, true),
|
146
|
+
getStyleRule(/\.(scss|sass)$/i, true, [
|
147
|
+
{
|
148
|
+
loader: 'sass-loader',
|
149
|
+
options: { sourceMap: true }
|
150
|
+
}
|
151
|
+
]),
|
152
|
+
getStyleRule(/\.(scss|sass)$/i, true, [
|
153
|
+
{
|
154
|
+
loader: 'sass-loader',
|
155
|
+
options: { sourceMap: true }
|
156
|
+
}
|
157
|
+
]),
|
158
|
+
<%- loaders.each do |loader| -%>
|
159
|
+
<%= loader %>,
|
160
|
+
<%- end -%>
|
161
|
+
],
|
162
|
+
},
|
163
|
+
resolveLoader: {
|
164
|
+
modules: ['node_modules'],
|
165
|
+
plugins: [PnpWebpackPlugin.moduleLoader(module)]
|
166
|
+
},
|
167
|
+
plugins: [
|
168
|
+
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(process.env))),
|
169
|
+
new CaseSensitivePathsPlugin(),
|
170
|
+
new MiniCssExtractPlugin({
|
171
|
+
filename: '[name]-[contenthash:8].css',
|
172
|
+
chunkFilename: '[name]-[contenthash:8].chunk.css'
|
173
|
+
}),
|
174
|
+
new WebpackAssetsManifest({
|
175
|
+
integrity: false,
|
176
|
+
entrypoints: true,
|
177
|
+
writeToDisk: true,
|
178
|
+
publicPath: true
|
179
|
+
}),
|
180
|
+
],
|
181
|
+
node: {
|
182
|
+
dgram: 'empty',
|
183
|
+
fs: 'empty',
|
184
|
+
net: 'empty',
|
185
|
+
tls: 'empty',
|
186
|
+
child_process: 'empty'
|
187
|
+
},
|
188
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "webpacker_ejector/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "webpacker_ejector"
|
8
|
+
spec.version = WebpackerEjector::VERSION
|
9
|
+
spec.authors = ["Kohei Hasegawa"]
|
10
|
+
spec.email = ["ameutau@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Eject webpacker}
|
13
|
+
spec.description = %q{Eject webpacker}
|
14
|
+
spec.homepage = "https://github.com/banyan/webpacker_ejector"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.8.4"
|
29
|
+
spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
|
30
|
+
spec.add_development_dependency "rails", "~> 6.0.0.beta3"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webpacker_ejector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kohei Hasegawa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-22 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: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 5.8.4
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 5.8.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-hooks
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.5.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.5.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 6.0.0.beta3
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 6.0.0.beta3
|
83
|
+
description: Eject webpacker
|
84
|
+
email:
|
85
|
+
- ameutau@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/generators/webpacker_ejector/eject_generator.rb
|
101
|
+
- lib/generators/webpacker_ejector/templates/webpack.config.js.erb
|
102
|
+
- lib/generators/webpacker_ejector/templates/webpacker.yml
|
103
|
+
- lib/webpacker_ejector.rb
|
104
|
+
- lib/webpacker_ejector/version.rb
|
105
|
+
- webpacker_ejector.gemspec
|
106
|
+
homepage: https://github.com/banyan/webpacker_ejector
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.7.6
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Eject webpacker
|
130
|
+
test_files: []
|