Skip to content

Commit f5bf5eb

Browse files
authored
Replace sprockets/browserify with Webpack (#2617)
* Replace browserify with webpack * Add react-intl-translations-manager * Do not minify in development, add offline-plugin for ServiceWorker background cache updates * Adjust tests and dependencies * Fix production deployments * Fix tests * More optimizations * Improve travis cache for npm stuff * Re-run travis * Add back support for custom.scss as before * Remove offline-plugin and babili * Fix issue with Immutable.List().unshift(...values) not working as expected * Make travis load schema instead of running all migrations in sequence * Fix missing React import in WarningContainer. Optimize rendering performance by using ImmutablePureComponent instead of React.PureComponent. ImmutablePureComponent uses Immutable.is() to compare props. Replace dynamic callback bindings in <UI /> * Add react definitions to places that use JSX * Add Procfile.dev for running rails, webpack and streaming API at the same time
1 parent 26bc591 commit f5bf5eb

File tree

343 files changed

+5282
-2064
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+5282
-2064
lines changed

.babelrc

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
{
2-
"presets": ["es2015", "react"],
2+
"presets": [
3+
"es2015",
4+
"react",
5+
[
6+
"env",
7+
{
8+
"loose": true,
9+
"modules": false
10+
}
11+
]
12+
],
313
"plugins": [
14+
"transform-react-jsx-source",
15+
"transform-react-jsx-self",
416
"transform-decorators-legacy",
5-
"transform-object-rest-spread"
17+
"transform-object-rest-spread",
18+
[
19+
"react-intl",
20+
{
21+
"messagesDir": "./build/messages"
22+
}
23+
]
624
]
725
}

.foreman

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
procfile: Procfile.dev

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public/assets
2222
.env
2323
.env.production
2424
node_modules/
25-
neo4j/
25+
build/
2626

2727
# Ignore Vagrant files
2828
.vagrant/
@@ -43,3 +43,5 @@ redis
4343
# Ignore vim files
4444
*~
4545
*.swp
46+
/public/packs
47+
/node_modules

.postcssrc.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
plugins:
2+
postcss-smart-import: {}
3+
precss: {}
4+
autoprefixer: {}

.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
language: ruby
22
cache:
33
bundler: true
4-
yarn: true
5-
directories:
6-
- node_modules
4+
yarn: false
75
dist: trusty
86
sudo: false
97

@@ -42,7 +40,8 @@ install:
4240
- yarn install
4341

4442
before_script:
45-
- bundle exec rails db:create db:migrate
43+
- bundle exec rails db:create db:schema:load
44+
- bundle exec rails assets:precompile
4645

4746
script:
4847
- bundle exec rspec

Dockerfile

+7-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ EXPOSE 3000 4000
1010

1111
WORKDIR /mastodon
1212

13-
COPY Gemfile Gemfile.lock package.json yarn.lock /mastodon/
14-
1513
RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
1614
&& BUILD_DEPS=" \
1715
postgresql-dev \
@@ -23,6 +21,7 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
2321
$BUILD_DEPS \
2422
nodejs@edge \
2523
nodejs-npm@edge \
24+
git \
2625
libpq \
2726
libxml2 \
2827
libxslt \
@@ -31,14 +30,14 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
3130
imagemagick@edge \
3231
ca-certificates \
3332
&& npm install -g npm@3 && npm install -g yarn \
34-
&& bundle install --deployment --without test development \
35-
&& yarn --ignore-optional \
36-
&& yarn cache clean \
37-
&& npm -g cache clean \
3833
&& update-ca-certificates \
39-
&& apk del $BUILD_DEPS \
4034
&& rm -rf /tmp/* /var/cache/apk/*
4135

36+
COPY Gemfile Gemfile.lock package.json yarn.lock /mastodon/
37+
38+
RUN bundle install --deployment --without test development \
39+
&& yarn --ignore-optional --pure-lockfile
40+
4241
COPY . /mastodon
4342

44-
VOLUME /mastodon/public/system /mastodon/public/assets
43+
VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs

Gemfile

+12-16
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,19 @@ ruby '>= 2.3.0', '< 2.5.0'
55

66
gem 'pkg-config'
77

8+
gem 'puma'
89
gem 'rails', '~> 5.0.2'
9-
gem 'sass-rails', '~> 5.0'
1010
gem 'uglifier', '>= 1.3.0'
11-
gem 'jquery-rails'
12-
gem 'puma'
1311

1412
gem 'hamlit-rails'
1513
gem 'pg'
1614
gem 'pghero'
1715
gem 'dotenv-rails'
18-
gem 'font-awesome-rails'
1916
gem 'best_in_place', '~> 3.0.1'
2017

18+
gem 'aws-sdk', '>= 2.0'
2119
gem 'paperclip', '~> 5.1'
2220
gem 'paperclip-av-transcoder'
23-
gem 'aws-sdk', '>= 2.0'
2421

2522
gem 'addressable'
2623
gem 'devise'
@@ -58,18 +55,18 @@ gem 'sprockets-rails', require: 'sprockets/railtie'
5855
gem 'statsd-instrument'
5956
gem 'twitter-text'
6057
gem 'tzinfo-data'
58+
gem 'webpacker', '~>1.2'
6159
gem 'whatlanguage'
6260

61+
# For some reason the view specs start failing without this
6362
gem 'react-rails'
64-
gem 'browserify-rails'
65-
gem 'autoprefixer-rails'
6663

6764
group :development, :test do
68-
gem 'rspec-rails'
69-
gem 'pry-rails'
70-
gem 'fuubar'
7165
gem 'fabrication'
66+
gem 'fuubar'
7267
gem 'i18n-tasks', '~> 0.9.6'
68+
gem 'pry-rails'
69+
gem 'rspec-rails'
7370
end
7471

7572
group :test do
@@ -83,24 +80,23 @@ group :test do
8380
end
8481

8582
group :development do
86-
gem 'rubocop', '0.46.0', require: false
83+
gem 'active_record_query_trace'
84+
gem 'annotate'
8785
gem 'better_errors'
8886
gem 'binding_of_caller'
87+
gem 'bullet'
8988
gem 'letter_opener'
9089
gem 'letter_opener_web'
91-
gem 'bullet'
92-
gem 'active_record_query_trace'
93-
gem 'annotate'
90+
gem 'rubocop', '0.46.0', require: false
9491

9592
gem 'capistrano', '3.8.0'
9693
gem 'capistrano-rails'
9794
gem 'capistrano-rbenv'
9895
gem 'capistrano-yarn'
99-
gem 'capistrano-faster-assets', '~> 1.0'
10096
end
10197

10298
group :production do
99+
gem 'lograge'
103100
gem 'rails_12factor'
104101
gem 'redis-rails'
105-
gem 'lograge'
106102
end

Gemfile.lock

+11-32
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ GEM
4343
public_suffix (~> 2.0, >= 2.0.2)
4444
airbrussh (1.2.0)
4545
sshkit (>= 1.6.1, != 1.7.0)
46-
annotate (2.7.1)
47-
activerecord (>= 3.2, < 6.0)
48-
rake (>= 10.4, < 12.0)
46+
annotate (2.6.5)
47+
activerecord (>= 2.3.0)
48+
rake (>= 0.8.7)
4949
arel (7.1.4)
5050
ast (2.3.0)
5151
attr_encrypted (3.0.3)
5252
encryptor (~> 3.0.0)
53-
autoprefixer-rails (6.7.7.2)
54-
execjs
5553
av (0.9.0)
5654
cocaine (~> 0.5.3)
5755
aws-sdk (2.9.12)
@@ -76,10 +74,6 @@ GEM
7674
rack (>= 0.9.0)
7775
binding_of_caller (0.7.2)
7876
debug_inspector (>= 0.0.1)
79-
browserify-rails (4.1.0)
80-
addressable (>= 2.4.0)
81-
railties (>= 4.0.0, < 5.1)
82-
sprockets (>= 3.6.0)
8377
builder (3.2.3)
8478
bullet (5.5.1)
8579
activesupport (>= 3.0.0)
@@ -92,8 +86,6 @@ GEM
9286
capistrano-bundler (1.2.0)
9387
capistrano (~> 3.1)
9488
sshkit (~> 1.2)
95-
capistrano-faster-assets (1.0.2)
96-
capistrano (>= 3.1)
9789
capistrano-rails (1.2.3)
9890
capistrano (~> 3.1)
9991
capistrano-bundler (~> 1.1)
@@ -161,8 +153,6 @@ GEM
161153
faker (1.7.3)
162154
i18n (~> 0.5)
163155
fast_blank (1.0.0)
164-
font-awesome-rails (4.7.0.1)
165-
railties (>= 3.2, < 5.1)
166156
fuubar (2.2.0)
167157
rspec-core (~> 3.0)
168158
ruby-progressbar (~> 1.4)
@@ -210,10 +200,6 @@ GEM
210200
rainbow (~> 2.2)
211201
terminal-table (>= 1.5.1)
212202
jmespath (1.3.1)
213-
jquery-rails (4.3.1)
214-
rails-dom-testing (>= 1, < 3)
215-
railties (>= 4.2.0)
216-
thor (>= 0.14, < 2.0)
217203
json (2.1.0)
218204
kaminari (1.0.1)
219205
activesupport (>= 4.1.0)
@@ -257,6 +243,7 @@ GEM
257243
mimemagic (0.3.2)
258244
mini_portile2 (2.1.0)
259245
minitest (5.10.1)
246+
multi_json (1.12.1)
260247
net-scp (1.2.1)
261248
net-ssh (>= 2.6.5)
262249
net-ssh (4.1.0)
@@ -348,8 +335,8 @@ GEM
348335
thor (>= 0.18.1, < 2.0)
349336
rainbow (2.2.2)
350337
rake
351-
rake (11.3.0)
352-
react-rails (1.11.0)
338+
rake (12.0.0)
339+
react-rails (2.1.0)
353340
babel-transpiler (>= 0.7.0)
354341
connection_pool
355342
execjs
@@ -410,13 +397,6 @@ GEM
410397
crass (~> 1.0.2)
411398
nokogiri (>= 1.4.4)
412399
nokogumbo (~> 1.4.1)
413-
sass (3.4.23)
414-
sass-rails (5.0.6)
415-
railties (>= 4.0.0, < 6)
416-
sass (~> 3.1)
417-
sprockets (>= 2.8, < 4.0)
418-
sprockets-rails (>= 2.0, < 4.0)
419-
tilt (>= 1.1, < 3)
420400
sidekiq (4.2.10)
421401
concurrent-ruby (~> 1.0)
422402
connection_pool (~> 2.2, >= 2.2.0)
@@ -473,6 +453,10 @@ GEM
473453
addressable (>= 2.3.6)
474454
crack (>= 0.3.2)
475455
hashdiff
456+
webpacker (1.2)
457+
activesupport (>= 4.2)
458+
multi_json (~> 1.2)
459+
railties (>= 4.2)
476460
websocket-driver (0.6.5)
477461
websocket-extensions (>= 0.1.0)
478462
websocket-extensions (0.1.2)
@@ -487,15 +471,12 @@ DEPENDENCIES
487471
active_record_query_trace
488472
addressable
489473
annotate
490-
autoprefixer-rails
491474
aws-sdk (>= 2.0)
492475
best_in_place (~> 3.0.1)
493476
better_errors
494477
binding_of_caller
495-
browserify-rails
496478
bullet
497479
capistrano (= 3.8.0)
498-
capistrano-faster-assets (~> 1.0)
499480
capistrano-rails
500481
capistrano-rbenv
501482
capistrano-yarn
@@ -507,7 +488,6 @@ DEPENDENCIES
507488
fabrication
508489
faker
509490
fast_blank
510-
font-awesome-rails
511491
fuubar
512492
goldfinger
513493
hamlit-rails
@@ -517,7 +497,6 @@ DEPENDENCIES
517497
http_accept_language
518498
httplog
519499
i18n-tasks (~> 0.9.6)
520-
jquery-rails
521500
kaminari
522501
letter_opener
523502
letter_opener_web
@@ -554,7 +533,6 @@ DEPENDENCIES
554533
rubocop (= 0.46.0)
555534
ruby-oembed
556535
sanitize
557-
sass-rails (~> 5.0)
558536
sidekiq
559537
sidekiq-unique-jobs
560538
simple-navigation
@@ -566,6 +544,7 @@ DEPENDENCIES
566544
tzinfo-data
567545
uglifier (>= 1.3.0)
568546
webmock
547+
webpacker (~> 1.2)
569548
whatlanguage
570549

571550
RUBY VERSION

Procfile.dev

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
web: bundle exec rails s -p 3000
2+
stream: yarn run start
3+
webpack: ./bin/webpack-dev-server

app/assets/javascripts/application.js

-15
This file was deleted.

app/assets/javascripts/application_public.js

-9
This file was deleted.

app/assets/javascripts/components.js

-15
This file was deleted.

0 commit comments

Comments
 (0)