Skip to content

Commit

Permalink
Replace sprockets/browserify with Webpack (mastodon#2617)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Gargron committed May 3, 2017
1 parent 26bc591 commit f5bf5eb
Show file tree
Hide file tree
Showing 343 changed files with 5,282 additions and 2,064 deletions.
22 changes: 20 additions & 2 deletions .babelrc
@@ -1,7 +1,25 @@
{
"presets": ["es2015", "react"],
"presets": [
"es2015",
"react",
[
"env",
{
"loose": true,
"modules": false
}
]
],
"plugins": [
"transform-react-jsx-source",
"transform-react-jsx-self",
"transform-decorators-legacy",
"transform-object-rest-spread"
"transform-object-rest-spread",
[
"react-intl",
{
"messagesDir": "./build/messages"
}
]
]
}
1 change: 1 addition & 0 deletions .foreman
@@ -0,0 +1 @@
procfile: Procfile.dev
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -22,7 +22,7 @@ public/assets
.env
.env.production
node_modules/
neo4j/
build/

# Ignore Vagrant files
.vagrant/
Expand All @@ -43,3 +43,5 @@ redis
# Ignore vim files
*~
*.swp
/public/packs
/node_modules
4 changes: 4 additions & 0 deletions .postcssrc.yml
@@ -0,0 +1,4 @@
plugins:
postcss-smart-import: {}
precss: {}
autoprefixer: {}
7 changes: 3 additions & 4 deletions .travis.yml
@@ -1,9 +1,7 @@
language: ruby
cache:
bundler: true
yarn: true
directories:
- node_modules
yarn: false
dist: trusty
sudo: false

Expand Down Expand Up @@ -42,7 +40,8 @@ install:
- yarn install

before_script:
- bundle exec rails db:create db:migrate
- bundle exec rails db:create db:schema:load
- bundle exec rails assets:precompile

script:
- bundle exec rspec
Expand Down
15 changes: 7 additions & 8 deletions Dockerfile
Expand Up @@ -10,8 +10,6 @@ EXPOSE 3000 4000

WORKDIR /mastodon

COPY Gemfile Gemfile.lock package.json yarn.lock /mastodon/

RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \
&& BUILD_DEPS=" \
postgresql-dev \
Expand All @@ -23,6 +21,7 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
$BUILD_DEPS \
nodejs@edge \
nodejs-npm@edge \
git \
libpq \
libxml2 \
libxslt \
Expand All @@ -31,14 +30,14 @@ RUN echo "@edge https://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/reposit
imagemagick@edge \
ca-certificates \
&& npm install -g npm@3 && npm install -g yarn \
&& bundle install --deployment --without test development \
&& yarn --ignore-optional \
&& yarn cache clean \
&& npm -g cache clean \
&& update-ca-certificates \
&& apk del $BUILD_DEPS \
&& rm -rf /tmp/* /var/cache/apk/*

COPY Gemfile Gemfile.lock package.json yarn.lock /mastodon/

RUN bundle install --deployment --without test development \
&& yarn --ignore-optional --pure-lockfile

COPY . /mastodon

VOLUME /mastodon/public/system /mastodon/public/assets
VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs
28 changes: 12 additions & 16 deletions Gemfile
Expand Up @@ -5,22 +5,19 @@ ruby '>= 2.3.0', '< 2.5.0'

gem 'pkg-config'

gem 'puma'
gem 'rails', '~> 5.0.2'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'puma'

gem 'hamlit-rails'
gem 'pg'
gem 'pghero'
gem 'dotenv-rails'
gem 'font-awesome-rails'
gem 'best_in_place', '~> 3.0.1'

gem 'aws-sdk', '>= 2.0'
gem 'paperclip', '~> 5.1'
gem 'paperclip-av-transcoder'
gem 'aws-sdk', '>= 2.0'

gem 'addressable'
gem 'devise'
Expand Down Expand Up @@ -58,18 +55,18 @@ gem 'sprockets-rails', require: 'sprockets/railtie'
gem 'statsd-instrument'
gem 'twitter-text'
gem 'tzinfo-data'
gem 'webpacker', '~>1.2'
gem 'whatlanguage'

# For some reason the view specs start failing without this
gem 'react-rails'
gem 'browserify-rails'
gem 'autoprefixer-rails'

group :development, :test do
gem 'rspec-rails'
gem 'pry-rails'
gem 'fuubar'
gem 'fabrication'
gem 'fuubar'
gem 'i18n-tasks', '~> 0.9.6'
gem 'pry-rails'
gem 'rspec-rails'
end

group :test do
Expand All @@ -83,24 +80,23 @@ group :test do
end

group :development do
gem 'rubocop', '0.46.0', require: false
gem 'active_record_query_trace'
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
gem 'bullet'
gem 'letter_opener'
gem 'letter_opener_web'
gem 'bullet'
gem 'active_record_query_trace'
gem 'annotate'
gem 'rubocop', '0.46.0', require: false

gem 'capistrano', '3.8.0'
gem 'capistrano-rails'
gem 'capistrano-rbenv'
gem 'capistrano-yarn'
gem 'capistrano-faster-assets', '~> 1.0'
end

group :production do
gem 'lograge'
gem 'rails_12factor'
gem 'redis-rails'
gem 'lograge'
end
43 changes: 11 additions & 32 deletions Gemfile.lock
Expand Up @@ -43,15 +43,13 @@ GEM
public_suffix (~> 2.0, >= 2.0.2)
airbrussh (1.2.0)
sshkit (>= 1.6.1, != 1.7.0)
annotate (2.7.1)
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
annotate (2.6.5)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
arel (7.1.4)
ast (2.3.0)
attr_encrypted (3.0.3)
encryptor (~> 3.0.0)
autoprefixer-rails (6.7.7.2)
execjs
av (0.9.0)
cocaine (~> 0.5.3)
aws-sdk (2.9.12)
Expand All @@ -76,10 +74,6 @@ GEM
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
browserify-rails (4.1.0)
addressable (>= 2.4.0)
railties (>= 4.0.0, < 5.1)
sprockets (>= 3.6.0)
builder (3.2.3)
bullet (5.5.1)
activesupport (>= 3.0.0)
Expand All @@ -92,8 +86,6 @@ GEM
capistrano-bundler (1.2.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-faster-assets (1.0.2)
capistrano (>= 3.1)
capistrano-rails (1.2.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
Expand Down Expand Up @@ -161,8 +153,6 @@ GEM
faker (1.7.3)
i18n (~> 0.5)
fast_blank (1.0.0)
font-awesome-rails (4.7.0.1)
railties (>= 3.2, < 5.1)
fuubar (2.2.0)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
Expand Down Expand Up @@ -210,10 +200,6 @@ GEM
rainbow (~> 2.2)
terminal-table (>= 1.5.1)
jmespath (1.3.1)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.1.0)
kaminari (1.0.1)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -257,6 +243,7 @@ GEM
mimemagic (0.3.2)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
Expand Down Expand Up @@ -348,8 +335,8 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rake (11.3.0)
react-rails (1.11.0)
rake (12.0.0)
react-rails (2.1.0)
babel-transpiler (>= 0.7.0)
connection_pool
execjs
Expand Down Expand Up @@ -410,13 +397,6 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (~> 1.4.1)
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sidekiq (4.2.10)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
Expand Down Expand Up @@ -473,6 +453,10 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
webpacker (1.2)
activesupport (>= 4.2)
multi_json (~> 1.2)
railties (>= 4.2)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand All @@ -487,15 +471,12 @@ DEPENDENCIES
active_record_query_trace
addressable
annotate
autoprefixer-rails
aws-sdk (>= 2.0)
best_in_place (~> 3.0.1)
better_errors
binding_of_caller
browserify-rails
bullet
capistrano (= 3.8.0)
capistrano-faster-assets (~> 1.0)
capistrano-rails
capistrano-rbenv
capistrano-yarn
Expand All @@ -507,7 +488,6 @@ DEPENDENCIES
fabrication
faker
fast_blank
font-awesome-rails
fuubar
goldfinger
hamlit-rails
Expand All @@ -517,7 +497,6 @@ DEPENDENCIES
http_accept_language
httplog
i18n-tasks (~> 0.9.6)
jquery-rails
kaminari
letter_opener
letter_opener_web
Expand Down Expand Up @@ -554,7 +533,6 @@ DEPENDENCIES
rubocop (= 0.46.0)
ruby-oembed
sanitize
sass-rails (~> 5.0)
sidekiq
sidekiq-unique-jobs
simple-navigation
Expand All @@ -566,6 +544,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
webmock
webpacker (~> 1.2)
whatlanguage

RUBY VERSION
Expand Down
3 changes: 3 additions & 0 deletions Procfile.dev
@@ -0,0 +1,3 @@
web: bundle exec rails s -p 3000
stream: yarn run start
webpack: ./bin/webpack-dev-server
15 changes: 0 additions & 15 deletions app/assets/javascripts/application.js

This file was deleted.

9 changes: 0 additions & 9 deletions app/assets/javascripts/application_public.js

This file was deleted.

15 changes: 0 additions & 15 deletions app/assets/javascripts/components.js

This file was deleted.

0 comments on commit f5bf5eb

Please sign in to comment.