js: bundle jQuery with Webpack.

Include jQuery in our Webpack bundle instead of loading it from CDNJS.
This means we no longer load any Javascript libraries from third party
sites.
This commit is contained in:
evazion
2020-06-30 23:00:44 -05:00
parent 94490eb57f
commit efe5111a9e
6 changed files with 13 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ require('jquery-hotkeys');
// should start looking for nodejs replacements
importAll(require.context('../vendor', true, /\.js$/));
require('jquery');
require("jquery-ui/ui/effects/effect-shake");
require("jquery-ui/ui/widgets/autocomplete");
require("jquery-ui/ui/widgets/button");
@@ -33,6 +34,7 @@ require("@fortawesome/fontawesome-free/css/regular.css");
importAll(require.context('../src/javascripts', true, /\.js(\.erb)?$/));
importAll(require.context('../src/styles', true, /\.s?css(?:\.erb)?$/));
export { default as jQuery } from "jquery";
export { default as Autocomplete } from '../src/javascripts/autocomplete.js.erb';
export { default as Blacklist } from '../src/javascripts/blacklists.js';
export { default as Comment } from '../src/javascripts/comments.js';

View File

@@ -6,7 +6,6 @@
<link rel="top" title="<%= Danbooru.config.app_name %>" href="/">
<%= csrf_meta_tag %>
<%= raw Danbooru.config.custom_html_header_content %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<%= javascript_pack_tag "application" %>
<%= stylesheet_pack_tag "application" %>
<%= yield :html_header %>

View File

@@ -14,7 +14,6 @@
<% if CurrentUser.user.blacklisted_tags.present? %>
<meta name="blacklisted-tags" content="<%= CurrentUser.user.blacklisted_tags.gsub(/(?:\r|\n)+/, ",") %>">
<% end %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<%= javascript_pack_tag "application" %>
<%= stylesheet_pack_tag "application" %>
<% if CurrentUser.user.custom_style.present? && params.fetch(:css, "true").truthy? %>
@@ -123,6 +122,8 @@
window.Danbooru.notice = Danbooru.Utility.notice;
window.Danbooru.error = Danbooru.Utility.error;
window.$ = Danbooru.jQuery;
window.jQuery = Danbooru.jQuery;
</script>
<%= render "static/footer" %>

View File

@@ -6,8 +6,8 @@ environment.loaders.append('erb', erb);
environment.config.output.library = ["Danbooru"];
environment.config.externals = {
jquery: "jQuery"
}
environment.config.set("resolve.alias", {
"jquery": "jquery/src/jquery.js"
});
module.exports = environment

View File

@@ -8,6 +8,7 @@
"dropzone": "^5.5.1",
"expose-loader": "^0.7.5",
"hammerjs": "^2.0.8",
"jquery": "3.4.1",
"jquery-hotkeys": "^0.2.2",
"jquery-ui": "^1.12.1",
"rails-erb-loader": "^5.5.0",

View File

@@ -4711,6 +4711,11 @@ jquery-ui@^1.12.1:
resolved "https://registry.yarnpkg.com/jquery-ui/-/jquery-ui-1.12.1.tgz#bcb4045c8dd0539c134bc1488cdd3e768a7a9e51"
integrity sha1-vLQEXI3QU5wTS8FIjN0+dop6nlE=
jquery@3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2"
integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==
js-base64@^2.1.8:
version "2.6.2"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.6.2.tgz#cf9301bc5cc756892a9a6c8d7138322e5944fb0d"