Skip to content

Commit

Permalink
Replaced jQuery wrapper with automatic vite import handling
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Feb 1, 2025
1 parent 822d84b commit 991d5a3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.1.4",
"gulp-shell": "^0.8.0",
"jquery": "^3.7.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
Expand Down
2 changes: 2 additions & 0 deletions src/ts/admin/root_selection.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import $ from 'jquery';

import { isError } from '../isError';
import { printError } from '../printError';

Expand Down
1 change: 1 addition & 0 deletions src/ts/admin/tinymce.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import $ from 'jquery';
import { default as tinymce } from 'tinymce';

import { isError } from '../isError';
Expand Down
1 change: 1 addition & 0 deletions src/ts/frontend/block/SgdgEditorComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as blockEditor from '@wordpress/block-editor';
import type { BlockEditProps } from '@wordpress/blocks';
import * as editor from '@wordpress/editor';
import { Component, createElement, Fragment } from '@wordpress/element';
import $ from 'jquery';

import { isError } from '../../isError';
import type { Attributes } from '../interfaces/Attributes';
Expand Down
1 change: 1 addition & 0 deletions src/ts/frontend/shortcode/Shortcode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ImageLightbox } from 'imagelightbox';
import $ from 'jquery';
import { default as justifiedLayout } from 'justified-layout';

import { isError } from '../../isError';
Expand Down
2 changes: 2 additions & 0 deletions src/ts/frontend/shortcode/ShortcodeRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import $ from 'jquery';

import { Shortcode } from './Shortcode';

interface ShortcodeRegistry {
Expand Down
17 changes: 1 addition & 16 deletions vite-builder.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
import { defineConfig, type PluginOption, type UserConfig } from 'vite';

function jQueryWrapperPlugin(): PluginOption {
return {
name: 'jQuery-wrapper',
generateBundle: (_, bundle): void => {
for (const file of Object.values(bundle)) {
if (file.type !== 'chunk') {
continue;
}
file.code = `jQuery(function ($) {${file.code}});\n`;
}
},
};
}
import { defineConfig, type UserConfig } from 'vite';

export function viteConfig(
sitePart: 'admin' | 'frontend',
Expand Down Expand Up @@ -54,6 +40,5 @@ export function viteConfig(
},
},
},
plugins: [jQueryWrapperPlugin()],
});
}

0 comments on commit 991d5a3

Please sign in to comment.