WIP: Handle CoffeeScript with Webpacker

This commit is contained in:
Andreas Nedbal 2020-12-25 03:33:49 +01:00 committed by Andreas Nedbal
parent df664d2772
commit 5d2ad96f42
39 changed files with 189 additions and 8 deletions

View File

@ -0,0 +1,4 @@
# Run this example by adding <%= javascript_pack_tag 'hello_coffee' %> to the head of your layout file,
# like app/views/layouts/application.html.erb.
console.log 'Hello world from coffeescript'

View File

@ -0,0 +1,8 @@
import './comment/destroy'
import './comment/report'
import './comment/smile'
import './comment'
import './destroy'
import './report'
import './smile'
import './subscribe'

View File

@ -1,3 +1,30 @@
import 'core-js/stable'
import 'regenerator-runtime/runtime'
import './jquery'
import 'popper.js'
import 'bootstrap'
import {} from 'jquery-ujs'
import 'jquery.turbolinks/src/jquery.turbolinks'
import 'jquery.guillotine'
import 'particleground/jquery.particleground.min'
import 'jquery.growl'
import NProgress from 'nprogress'
import Cookies from 'js-cookie'
import './answerbox'
import './questionbox'
import './inbox'
import './memes'
import './notifications'
import './pagination'
import './question'
import './settings'
import './user'
import './report'
import './locale-box'
import './util'
#= require jquery3
#= require jquery_ujs
#= require jquery.turbolinks
@ -29,7 +56,7 @@
#= require user
#= require report
#= require locale-box
#= require util
# not required:
# _tree ./moderation

View File

@ -0,0 +1,9 @@
# HACK: Can't believe I have to do this, but this is a workaround
# as long as we have to deal with all the legacy code
#
# We're going to set up a global jQuery instance here and configure it
# with all our plugins because with newfangled bundling the old approach
# and especially jQuery doesn't really work out
import jQuery from 'jquery'
window.$ = window.jQuery = jQuery

View File

@ -1,3 +1,5 @@
import cheet from 'cheet.js'
cheet 'up up down down left right left right b a', ->
($ "body").addClass 'fa-spin'
($ "p.answerbox__question-text").each (i) -> ($ this).html ":^)"

View File

@ -0,0 +1,14 @@
import '../jquery'
import 'popper.js'
import 'bootstrap'
import {} from 'jquery-ujs'
import 'jquery.turbolinks/src/jquery.turbolinks'
import 'jquery.guillotine'
import 'particleground/jquery.particleground.min'
import 'jquery.growl'
import './ban'
import './comment'
import './destroy'
import './privileges'
import './vote'

View File

@ -0,0 +1,4 @@
import './all'
import './destroy'
import './report'
import './user'

View File

@ -1,3 +1,5 @@
import tinycolor from 'tinycolor2'
window.doppler = (percentage, value, relative = false) ->
while percentage >= 1
percentage /= 10

View File

@ -12,9 +12,9 @@
%title= yield(:title)
= javascript_include_tag 'i18n', data: { 'turbolinks-track': true }
= stylesheet_link_tag 'application', media: 'all', data: { 'turbolinks-track': true }
= javascript_include_tag 'application', data: { 'turbolinks-track': true }
= javascript_pack_tag 'legacy/application', data: { 'turbolinks-track': true }
- if user_signed_in? && current_user.mod?
= javascript_include_tag 'moderation', data: { 'turbolinks-track': true }
= javascript_pack_tag 'legacy/moderation/index', data: { 'turbolinks-track': true }
= csrf_meta_tags
%body
- if user_signed_in?

View File

@ -1,8 +1,30 @@
{
"dependencies": {
"@rails/webpacker": "5.2.1"
"bootstrap": "^4.5.3",
"cheet.js": "^0.3.3",
"core-js": "^3.8.1",
"jquery": "^3.5.1",
"jquery-minicolors": "^2.1.10",
"jquery-ujs": "^1.2.2",
"jquery.growl": "^1.3.5",
"jquery.guillotine": "^1.4.3",
"jquery.turbolinks": "^2.1.0",
"js-cookie": "2.2.1",
"nprogress": "^0.2.0",
"particleground": "jnicol/particleground",
"popper.js": "^1.16.1",
"regenerator-runtime": "^0.13.7",
"sweetalert": "1.1.3",
"tinycolor2": "^1.4.2",
"turbolinks": "turbolinks/turbolinks-classic"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@rails/webpacker": "5.2.1",
"coffee-loader": "^2.0.0",
"coffeescript": "^2.5.1",
"webpack": "^4",
"webpack-dev-server": "^3.11.0"
}
}

View File

@ -14,7 +14,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.12.7.tgz#9329b4782a7d6bbd7eef57e11addf91ee3ef1e41"
integrity sha512-YaxPMGs/XIWtYqrdEOZOCPsVWfEoriXopnsz3/i7apYPXQ3698UFhS6dVT1KN5qOsWmVgw/FOrmQgpRaZayGsw==
"@babel/core@^7.11.1":
"@babel/core@^7.11.1", "@babel/core@^7.12.10":
version "7.12.10"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.12.10.tgz#b79a2e1b9f70ed3d84bbfb6d8c4ef825f606bccd"
integrity sha512-eTAlQKq65zHfkHZV0sIVODCPGVgoo1HdBlbSLi9CqOzuZanMv2ihzY+4paiKr1mH+XmYESMAmJ/dpZ68eN6d8w==
@ -700,7 +700,7 @@
"@babel/helper-create-regexp-features-plugin" "^7.12.1"
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/preset-env@^7.11.0":
"@babel/preset-env@^7.11.0", "@babel/preset-env@^7.12.11":
version "7.12.11"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.12.11.tgz#55d5f7981487365c93dbbc84507b1c7215e857f9"
integrity sha512-j8Tb+KKIXKYlDBQyIOy4BLxzv1NUOwlHfZ74rvW+Z0Gp4/cI2IMDPBWAgWceGcE7aep9oL/0K9mlzlMGxA8yNw==
@ -1471,6 +1471,11 @@ boolbase@^1.0.0, boolbase@~1.0.0:
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24=
bootstrap@^4.5.3:
version "4.5.3"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.5.3.tgz#c6a72b355aaf323920be800246a6e4ef30997fe6"
integrity sha512-o9ppKQioXGqhw8Z7mah6KdTYpNQY//tipnkxppWhPbiSWdD+1raYsnhwEZjkTHYbGee4cVQ0Rx65EhOY/HNLcQ==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
@ -1772,6 +1777,11 @@ chalk@^2.0, chalk@^2.0.0, chalk@^2.4.1, chalk@^2.4.2:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
cheet.js@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/cheet.js/-/cheet.js-0.3.3.tgz#c98e5fdefc8c6241a1cd6dcf71a09b063887daed"
integrity sha1-yY5f3vyMYkGhzW3PcaCbBjiH2u0=
chokidar@^2.1.8:
version "2.1.8"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917"
@ -1878,6 +1888,16 @@ code-point-at@^1.0.0:
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
coffee-loader@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/coffee-loader/-/coffee-loader-2.0.0.tgz#76f4e193074cea8bf3e226aaed5ea356d3380c1b"
integrity sha512-fCq1T1b8ByUiPcWRMe3HCgvfS9h8kahRWR44Mew57x7Xm5MsNg9mjnV4XHHj6rWQS2+8SMYavHJQHQDUNybqhw==
coffeescript@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-2.5.1.tgz#b2442a1f2c806139669534a54adc35010559d16a"
integrity sha512-J2jRPX0eeFh5VKyVnoLrfVFgLZtnnmp96WQSLAS8OrLm2wtQLcnikYKe1gViJKDH7vucjuhHvBKKBP3rKcD1tQ==
collection-visit@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0"
@ -2066,7 +2086,7 @@ core-js-compat@^3.8.0:
browserslist "^4.15.0"
semver "7.0.0"
core-js@^3.6.5:
core-js@^3.6.5, core-js@^3.8.1:
version "3.8.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.8.1.tgz#f51523668ac8a294d1285c3b9db44025fda66d47"
integrity sha512-9Id2xHY1W7m8hCl8NkhQn5CufmF/WuR30BTRewvCXc1aZd3kMECwNZ69ndLbekKfakw9Rf2Xyc+QR6E7Gg+obg==
@ -3981,11 +4001,52 @@ jest-worker@^26.5.0:
merge-stream "^2.0.0"
supports-color "^7.0.0"
jquery-minicolors@^2.1.10:
version "2.1.10"
resolved "https://registry.yarnpkg.com/jquery-minicolors/-/jquery-minicolors-2.1.10.tgz#b29eea541d9a32b4e26923168fb2c16271867379"
integrity sha1-sp7qVB2aMrTiaSMWj7LBYnGGc3k=
dependencies:
jquery ">= 1.7.x"
jquery-ujs@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/jquery-ujs/-/jquery-ujs-1.2.2.tgz#6a8ef1020e6b6dda385b90a4bddc128c21c56397"
integrity sha1-ao7xAg5rbdo4W5CkvdwSjCHFY5c=
dependencies:
jquery ">=1.8.0"
jquery.growl@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/jquery.growl/-/jquery.growl-1.3.5.tgz#fa1c4d758e0d7686551e15896b1aaac2bb1af7f1"
integrity sha1-+hxNdY4NdoZVHhWJaxqqwrsa9/E=
jquery.guillotine@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/jquery.guillotine/-/jquery.guillotine-1.4.3.tgz#c2463c367feaa8b229e02e2fbbae2e29cfd07225"
integrity sha1-wkY8Nn/qqLIp4C4vu64uKc/QciU=
dependencies:
jquery ">= 1.8.0"
jquery.turbolinks@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/jquery.turbolinks/-/jquery.turbolinks-2.1.0.tgz#36036bb997c48d53bceb345521fbdf7da887a62c"
integrity sha1-NgNruZfEjVO86zRVIfvffaiHpiw=
"jquery@>= 1.7.x", "jquery@>= 1.8.0", jquery@>=1.8.0, jquery@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==
js-base64@^2.1.8:
version "2.6.4"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4"
integrity sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==
js-cookie@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@ -4728,6 +4789,11 @@ npm-run-path@^2.0.0:
gauge "~2.7.3"
set-blocking "~2.0.0"
nprogress@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/nprogress/-/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1"
integrity sha1-y480xTIT2JVyP8urkH6UIq28r7E=
nth-check@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c"
@ -5018,6 +5084,10 @@ parseurl@~1.3.2, parseurl@~1.3.3:
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4"
integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==
particleground@jnicol/particleground:
version "0.0.0"
resolved "https://codeload.github.com/jnicol/particleground/tar.gz/124f7dbe732693ff5ab7f6c9edaea46acd2416a2"
pascalcase@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
@ -5158,6 +5228,11 @@ pnp-webpack-plugin@^1.6.4:
dependencies:
ts-pnp "^1.1.6"
popper.js@^1.16.1:
version "1.16.1"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==
portfinder@^1.0.26:
version "1.0.28"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778"
@ -6923,6 +6998,11 @@ svgo@^1.0.0:
unquote "~1.1.1"
util.promisify "~1.0.0"
sweetalert@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/sweetalert/-/sweetalert-1.1.3.tgz#d2c31ea492b22b6a8d887aea15989a238fc084ae"
integrity sha1-0sMepJKyK2qNiHrqFZiaI4/AhK4=
tapable@^1.0.0, tapable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2"
@ -7022,6 +7102,11 @@ timsort@^0.3.0:
resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
tinycolor2@^1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.2.tgz#3f6a4d1071ad07676d7fa472e1fac40a719d8803"
integrity sha512-vJhccZPs965sV/L2sU4oRQVAos0pQXwsvTLkWYdqJ+a8Q5kPFzJTuOFwy7UniPli44NKQGAglksjvOcpo95aZA==
to-arraybuffer@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
@ -7111,6 +7196,10 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"
turbolinks@turbolinks/turbolinks-classic:
version "0.0.1"
resolved "https://codeload.github.com/turbolinks/turbolinks-classic/tar.gz/80216ce9d89920bf073709405e3fce6d0a3ccd9a"
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
@ -7439,7 +7528,7 @@ webpack-sources@^1.0.0, webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-
source-list-map "^2.0.0"
source-map "~0.6.1"
webpack@^4.44.1:
webpack@^4, webpack@^4.44.1:
version "4.44.2"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.44.2.tgz#6bfe2b0af055c8b2d1e90ed2cd9363f841266b72"
integrity sha512-6KJVGlCxYdISyurpQ0IPTklv+DULv05rs2hseIXer6D7KrUicRDLFb4IUM1S6LUAKypPM/nSiVSuv8jHu1m3/Q==