aboutsummaryrefslogtreecommitdiff
path: root/webpack.config.js
AgeCommit message (Collapse)Author
2023-03-04update to mermaid v10 (#23178)techknowlogick
fix #23153 --------- Co-authored-by: silverwind <me@silverwind.io>
2023-02-17Introduce customized HTML elements, fix incorrect AppUrl usages in templates ↵wxiaoguang
(#22861) This PR follows: * #21986 * #22831 This PR also introduce customized HTML elements, which would also help problems like: * #17760 * #21429 * #21440 With customized HTML elements, there won't be any load-search-replace operations, and it can avoid page flicking (which @silverwind cares a lot). Browser support: https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements # FAQ ## Why the component has the prefix? As usual, I would strongly suggest to add prefixes for our own/private names. The dedicated prefix will avoid conflicts in the future, and it makes it easier to introduce various 3rd components, like GitHub's `relative-time` component. If there is no prefix, it's impossible to introduce another public component with the same name in the future. ## Why the `custcomp.js` is loaded before HTML body? The `index.js` is after HTML body. Customized components must be registered before the content loading. Otherwise there would be still some flicking. `custcomp.js` should have its own dependencies and should be very light, so it won't affect the page loading time too much. ## Why use `data-url` attribute but not use the `textContent`? According to the standard, the `connectedCallback` occurs on the tag-opening moment. The element's children are not ready yet. ## Why not use `{{.GuessCurrentOrigin $.ctx ...}}` to let backend decide the absolute URL? It's difficult for backend to guess the correct protocol(scheme) correctly with zero configuration. Generating the absolute URL from frontend can guarantee that the URL is 100% correct -- since the user is visiting it. # Screenshot <details> ![image](https://user-images.githubusercontent.com/2114189/218256757-a267c8ba-3108-4755-9ae5-329f1b08f615.png) </details>
2022-12-20Update JS dependencies and eslint (#22190)silverwind
- Update all JS dependencies to latest version - Enable unicorn/prefer-node-protocol and autofix issues - Regenerate SVGs - Add some comments to eslint rules - Tested build, Mermaid and Katex rendering
2022-11-22Update JS dependencies (#21881)silverwind
- Update all JS deps - Regenerate SVGs - Add new eslint rules, fix issues - Tested Mermaid, Swagger, Vue, Webpack, Citation Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-18Fix webpack license warning (#21815)silverwind
#19999 introduced a indirect dependency with a license that was not on our allowlist yet which produced this warning during webpack: ```` WARNING in License: citeproc@2.4.62 has disallowed license CPAL-1.0 OR AGPL-1.0 ```` I've added both licenses to the allowed list and made it so webpack will now abort on such license errors so that we don't miss those next time. Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-18chore: add webpack export type check (#21857)Percy Ma
add webpack export type check Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-10Update JS dependencies and eslint config (#21388)silverwind
- Update all JS dependencies and playwright image - Add new eslint rules, enable a few more, fix issues - Regenerate SVGs - Tested Vue and Swagger Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-01Refactor from Vue2 to Vue3 (#20044)André Jaenisch
Close #19902
2022-09-14Add KaTeX rendering to Markdown. (#20571)zeripath
This PR adds mathematical rendering with KaTeX. The first step is to add a Goldmark extension that detects the latex (and tex) mathematics delimiters. The second step to make this extension only run if math support is enabled. The second step is to then add KaTeX CSS and JS to the head which will load after the dom is rendered. Fix #3445 Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-09-07Rewrite go license generator in go (#21078)silverwind
This removes the JS dependency in the checks pipeline. JSON output is different because the previous JS did indent the license data differently and a JSON key was changed, but the end result is the same as it gets re-indented by wepack. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
2022-09-04Add go licenses to licenses.txt (#21034)silverwind
`make go-licenses` will generate `assets/go-licenses.json` which is then included in the webpack build. This step depends on both go and node being present, so unfortunately, I could not automate the generation by hooking it up to `tidy` as that target is triggered on CI where we do not have a docker image with both go an node. It should be ran from time to time, ideally after each go mod update.
2022-08-23Enable contenthash in filename for dynamic assets (#20813)silverwind
This should solve the main problem of dynamic assets getting stale after a version upgrade. Everything not affected will use query-string based cache busting, which includes files loaded via HTML or worker scripts.
2022-07-20Update JS dependencies (#20423)silverwind
- Update all JS dependencies minus vue ones - Remove workaround for case-insensitive attribute selector - Add new linter rules and fix issues - Tested SVG display and swagger
2022-06-06Modernize JS build scripts (#19824)silverwind
- Remove __dirname, use file URLs instead - Upgrade fabric dependency - Use fs/promises syntax, this breaks node 12 but we require 14 already The change in public/img/favicon.svg is not caused by the fabric upgrade, but it seems it was not properly generated when introduced. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-14Support webauthn (#17957)Lunny Xiao
Migrate from U2F to Webauthn Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-07Fix CSS specificity issue with easymde's css (#18201)silverwind
* Fix CSS specificity issue with easymde's css PR #18069 introduced a regression in certain overwritten editor styles because the dynamic loading of easymde.min.css causes its's style to apply after our supposed override styles. Solve this by bundling the styles into index.css. We should later aim to completely replace easymde.min.css completely with our own styles so there are no more conflicts. * Update web_src/js/features/comp/EasyMDE.js Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-05Load EasyMDE/CodeMirror dynamically, remove RequireEasyMDE (#18069)wxiaoguang
This PR makes frontend load EasyMDE/CodeMirror dynamically, and removes `RequireEasyMDE`.
2021-10-19Update JS dependencies (#17357)silverwind
* Update JS dependencies - Upgrade to eslint 8 and add new plugin rules - Adapt to various API changes - Rebuild SVGs * fix webpack warning on license * order options alphabetically Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-17Update JS dependencies (#16708)silverwind
* Update JS dependencies - Update all JS dependencies - Adapt to recent webpack changes - Add new lint rules and fix issues - Regenerate SVGs and update svgo api usage Fixes: https://github.com/go-gitea/gitea/pull/16492 * adapt jest config and sort keys Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-19Disable legal comments in esbuild (#15929)silverwind
We already serve licenses.txt so we don't need these inline comments preserved during esbuild minification. Saves around 4kB before gzip.
2021-05-07Use esbuild to minify CSS (#15756)silverwind
It's about a 30% speedup in webpack build time with neglible differences in the output size. We do lose the ability for CSS source maps, but I rarely have a use for them anyways. Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: 6543 <6543@obermui.de>
2021-04-24Update JS dependencies (#15591)silverwind
* Update JS dependencies - Update all JS dependencies - Regenerate SVGs - Remove unused postcss dependency - Remove removed webpack option * re-add postcss Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-22Raw file view tweaks (#15520)silverwind
- Limit SVG images to 600px width - Adjust size of view toggle buttons to match other buttons - Make Edit/Delete buttons easier to click Had to create a separate CSS file because the less parser can not parse CSS4 case-insensitive attribute selectors which are widely supported by browsers. Fixes: https://github.com/go-gitea/gitea/issues/15515
2021-04-16Fix missing icons and colorpicker when mounted on suburl (#15501)zeripath
* Fix missing icons and colorpicker when mounted on suburl Signed-off-by: Andrew Thornton <art27@cantab.net> * as per silverwind Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
2021-04-15Fix: npx webpack make: *** [Makefile:699: public/js/index.js] Error -… ↵Kindyroo
(#15465) * Fix: npx webpack make: *** [Makefile:699: public/js/index.js] Error -1073741819 * Update webpack.config.js Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
2021-04-08Disable cssnano's colormin plugin (#15347)silverwind
It produces odd rgba values which also seem to cause issues in monaco's color parser where the scoll shadow went red for some reason. Regression by: https://github.com/go-gitea/gitea/pull/15333
2021-04-08Add frontend testing, require node 12 (#15315)silverwind
- Add basic frontend unit testing infrastructure using jest in ESM mode - Rename 'make test' to 'make test-backend' - Introduce 'make test-frontend' and 'make test' that runs both - Bump Node.js requirement to v12. v10 will be EOL in less than a month. - Convert all build-related JS files to ESM. I opted to run frontend tests run as part of the compliance pipeline because they complete fast and are not platform-specific like the golang tests.
2021-04-02Introduce esbuild on webpack (#14578)Lunny Xiao
* Vendor node mods as cache; fix esbuild/fomantic offline build * Fix --exclude; use bsdtar for consistent globbing * Fall back to GNU tar; forward-compatible for APT 2.0 * Avoid having extd. attrs with bsdtar * Dependency and misc. optimizations * Remove extra code after esbuild-loader update Co-authored-by: Mike L <cl.jeremy@qq.com>
2021-03-30Remove file-loader dependency (#15196)silverwind
- Upgrade webpack to 5.28 to enable publicPath option - Use asset modules in place of deprecated file-loader Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-22Remove raw-loader dependency (#15112)silverwind
Webpack now includes this functionality, allowing us to drop this now-deprecated dependency. Ref: https://webpack.js.org/guides/asset-modules/ Ref: https://webpack.js.org/loaders/raw-loader/
2020-12-27Update JS dependencies and webpack (#14118)silverwind
* Update JS dependencies - Update all JS dependencies - Adapt webpack config for version 5 - Update to Less 4.0, adapting usage of removed mixin syntax - Enable new ESLint rules and fix discovered issues * update license-webpack-plugin to fix missing licenses * update license-webpack-plugin once more to get webpack into the license output * switch to license-checker-webpack-plugin again for performance * update deps again Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-10Switch from SimpleMDE to EasyMDE (#13333)zeripath
* Switch from SimpleMDE to EasyMDE Signed-off-by: Andrew Thornton <art27@cantab.net> * use webpack to webpack the easymde css Signed-off-by: Andrew Thornton <art27@cantab.net> * move css to only css Signed-off-by: Andrew Thornton <art27@cantab.net> * move loading codemirror modes and addons back in to footer.tmpl Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix arc-green Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @silverwind * reinstall codemirror Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-19Use CSS Variables for fonts, remove postcss-loader (#13204)silverwind
* Use CSS Variables for fonts, remove postcss-loader - Use CSS variables for fonts, making the fonts easier to customize - Remove postcss-loader, it's not doing anything useful and is actually applying strange transforms on our CSS. Fixes: https://github.com/go-gitea/gitea/issues/11045 * introduce helper variable, mark documented vars * work around case issue by always quoting specific fonts
2020-09-10Update JS dependencies (#12782)silverwind
- Update all dependencies - Add explicit postcss dependency as dictated by postcss-loader - Adapt for new postcss-loader syntax - Move sourceMap options to top for consistency Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-28Avoid unnecessary system-ui expansion (#12522)Mike L
* Avoid unnecessary system-ui expansion (fix #12325) * extract config to static object Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-26Extract Swagger CSS to its own file (#12616)silverwind
2020-08-21Speed up licenses.txt build during development, add additionalModules (#12510)silverwind
- Emit static string for licenses.txt during development for faster builds - Manually add @primer/octicons to licenses.txt because it's never directy imported. Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-12Update JS dependencies (#12474)silverwind
* Update JS dependencies - Update worker-loader options (currently unused pending #12459) - Remove @babel/plugin-proposal-object-rest-spread, it's enabled by default - Switch cssnano-webpack-plugin to css-minimizer-webpack-plugin which had been renamed * switch to css-minimizer-webpack-plugin
2020-08-02Split up monaco's language chunks (#12401)silverwind
This should speed up monaco's loading time by splitting the current 3.71MB chunk monaco.js into 63 individual files named 1 to 63.js in the output directory. There seems to be no way to get a better file naming scheme unfortunately. I opted to exclude those files in the webpack output for brevity.
2020-07-29Move jquery-minicolors to npm/webpack (#12305)silverwind
* Move jquery-minicolors to npm/webpack - Unvendor and add as npm dependency - Removed unneeded backend variable - Fixed existing bug where picker would previously initizalize to the same green color when editing a label. There was probably a version bump because the previous version was over 3 years old but it seems to be compatible. * use file-loader * trailing comma and comment update * misc tweaks Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-27Update JS deps and linting config (#12295)silverwind
- update js deps to latest versions - remove eslint-plugin-sonarjs to prevent a warning on install. can be added again once it's updated to support eslint 7.x - enable new linting rules from eslint-plugin-unicorn Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-12Direct SVG rendering (#12157)silverwind
Introduce 'make svg' which calls a node script that compiles svg files to `public/img/svg`. These files are vendored to not create a dependency on Node for the backend build. On the frontend side, configure webpack using `raw-loader` so SVGs can be imported as string. Also moved our existing SVGs to web_src/svg for consistency. Fixes: https://github.com/go-gitea/gitea/issues/11618
2020-07-06Fonts rework (#12114)silverwind
- Use system fonts only for text to avoid FOUT - Move font-awesome to npm/webpack - Move NotoColorEmoji to web_src - Remove presumably unneccesary 'PT Sans Narrow' - Simplify webpack import exclusions Fixes: https://github.com/go-gitea/gitea/issues/11818 Fixes: https://github.com/go-gitea/gitea/pull/11814 Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-03Move EventSource to SharedWorker (#12095)zeripath
Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1 open browser connections from preventing gitea from opening multiple tabs. Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating Fix #11978 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-01Fix missing gitgraph css import (#12112)silverwind
The filter was wrongly excluding the gitGraph.css file. Need to clean this up later so that imports are always relative to the source file (which is not the case for fonts right now). Regressed by: https://github.com/go-gitea/gitea/pull/11997 Co-authored-by: zeripath <art27@cantab.net>
2020-07-01Server-side syntax highlighting for all code (#12047)mrsdizzie
* Server-side syntax hilighting for all code This PR does a few things: * Remove all traces of highlight.js * Use chroma library to provide fast syntax hilighting directly on the server * Provide syntax hilighting for diffs * Re-style both unified and split diffs views * Add custom syntax hilighting styling for both regular and arc-green Fixes #7729 Fixes #10157 Fixes #11825 Fixes #7728 Fixes #3872 Fixes #3682 And perhaps gets closer to #9553 * fix line marker * fix repo search * Fix single line select * properly load settings * npm uninstall highlight.js * review suggestion * code review * forgot to call function * fix test * Apply suggestions from code review suggestions from @silverwind thanks Co-authored-by: silverwind <me@silverwind.io> * code review * copy/paste error * Use const for highlight size limit * Update web_src/less/_repository.less Co-authored-by: Lauris BH <lauris@nix.lv> * update size limit to 1MB and other styling tweaks * fix highlighting for certain diff sections * fix test * add worker back as suggested Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-28Use custom SVGs for commit signing lock icon (#12017)Cirno the Strongest
* Use custom SVGs for commit signing lock icon * missing spans * editorconfig * xmlns and remove aria-hidden Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-27Move fomantic and jQuery to main webpack bundle (#11997)silverwind
This saves around 3 MB binary size by not including useless fomantic files in the build. Also, this allows us to move jQuery into the main bundle as well which eliminates a few HTTP requests. Also included are webpack config changes: - split less and css loaders to speed up compliation - enable css sourcemaps - switch css minfier plugin to cssnano-webpack-plugin which works better for sourcemaps than the previous plugin Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-12Add automatic JS license generation (#11810)silverwind
* Add automatic JS license generation Removed librejs file and replaced it with a plaintext file that is built from all JS dependencies that are included in the webpack build. It does not cover the few remaining statically vendored files and fomantic is added manually because it's not yet in the webpack build process. Fixes: https://github.com/go-gitea/gitea/issues/11630 * fix lint * remove jslicense, we're not librejs compatible any more * remove license.txt test as it depens on absent files * small optimization * trailing comma * localize and capitalize the word 'licenses' * reduce text to just 'Licenses' Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-10Replace jquery-datetimepicker with native date input (#11684)silverwind
This removes the jQuery plugin as well as the associated config options. Native input[type=date] does not require a language attribute as it is localized by default, except for the placeholder attribute for which I currently piggy-back the repo.issues.due_date_form localization option. Implementation should pretty much match GH. Of note is that Safari does not provide a UI for this input type, but I don't think providing one is neccessary and GH did not bother either. Co-authored-by: techknowlogick <techknowlogick@gitea.io>