Skip to content

Commit

Permalink
Install jquery through webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed Oct 11, 2024
1 parent 2246fa1 commit 9f51d4b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion qgis-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"highlight.js": "^11.9.0",
"jquery": "^3.7.1"
},
"devDependencies": {
"css-loader": "^6.8.1",
"highlight.js": "^11.9.0",
"mini-css-extract-plugin": "^2.7.6",
"sass": "^1.77.8",
"sass-loader": "^13.3.2",
Expand Down
5 changes: 4 additions & 1 deletion qgis-app/static/js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require('../style/scss/style.scss');
import $ from 'jquery';

window.$ = $;

document.addEventListener('DOMContentLoaded', () => {

Expand All @@ -21,4 +24,4 @@ require('../style/scss/style.scss');
});
});

});
});
6 changes: 0 additions & 6 deletions qgis-app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

<link rel="shortcut icon" href="{% static "images/favicon.ico" %}"/>

<script type="text/javascript" src="{% static "js/jquery-1.11.1.min.js" %}"></script>
<script type="text/javascript" src="{% static "bootstrap/js/bootstrap-3.4.1.min.js" %}"></script>

<!-- Cookie disclaimer -->
<script type="text/javascript" id="cookieinfo" src="{% static 'js/cookieinfo/cookieinfo.min.js' %}" data-bg="#1c2028"
data-fg="#FFFFFF" data-link="#22961c" data-cookie="CookieInfoScript" data-text-align="left"
Expand Down Expand Up @@ -70,9 +67,6 @@
{{ sustaining_members_section|safe }}
{% include 'layouts/footer.html' %}

<script type="text/javascript">
$('#user-tooltip').tooltip('hide');
</script>
<script type="text/javascript" src="{% static 'js/moment.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/local_timezone-1.0.js' %}"></script>
<style>
Expand Down
8 changes: 7 additions & 1 deletion qgis-app/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path');
const BundleTracker = require('webpack-bundle-tracker');
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');

const mode = process.argv.indexOf("production") !== -1 ? "production" : "development";
console.log(`Webpack mode: ${mode}`);
Expand All @@ -10,6 +11,11 @@ let plugins = [
new MiniCssExtractPlugin({
filename: 'css/[name].[contenthash].css',
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
];

if (mode === 'development') {
Expand Down

0 comments on commit 9f51d4b

Please sign in to comment.