#4052 webpack upatde

Closed
zhoupzh wants to merge 15 commits from fix-3325 into V20230425
  1. +2
    -1
      .gitignore
  2. +4
    -4
      Makefile
  3. +11490
    -12768
      package-lock.json
  4. +14
    -12
      package.json
  5. BIN
      public/0acc017d3b9b32f1f61a9af2315d5187.png
  6. BIN
      public/0f1600ced2415ea9530a1a55ec045fef.png
  7. BIN
      public/1f2e7b26b1be5e67e613178f38625008.png
  8. BIN
      public/276e9642cca7e5f8958c004269a6c0d7.png
  9. BIN
      public/41fa1ffe704082c381ae88ea686c9f39.png
  10. BIN
      public/5920c99e273bded4a2c702d4a1ed59ee.png
  11. BIN
      public/6f562e238482d4479212cbf367f6a293.png
  12. BIN
      public/71261d74041a4133ae4b9908d4a8109f.png
  13. BIN
      public/d4f9fbedc79f92e41f984283b6227127.png
  14. +1
    -0
      public/img/svg/icons.svg
  15. +0
    -0
      tsconfig.json
  16. +2
    -3
      web_src/js/components/Contributors.vue
  17. +1
    -1
      web_src/js/components/EditTopics.vue
  18. +3
    -2
      web_src/js/features/highlight.js
  19. +70
    -96
      web_src/js/features/letteravatar.js
  20. +0
    -1
      web_src/js/index.js
  21. +2
    -2
      web_src/vuepages/pages/ros-hmci/components/helpCollaps.vue
  22. +5
    -5
      web_src/vuepages/pages/ros-hmci/style/index.less
  23. +1
    -1
      web_src/vuepages/pages/ros-hmci/vp-ros-hmci.js
  24. +120
    -140
      webpack.config.js
  25. +115
    -135
      webpack_pro.config.js
  26. +1790
    -2721
      yarn.lock

+ 2
- 1
.gitignore View File

@@ -82,7 +82,8 @@ coverage.all
/public/css
/public/fonts
/public/fomantic
/public/img/svg

/public/img/webpack
/VERSION




+ 4
- 4
Makefile View File

@@ -90,7 +90,7 @@ WEBPACK_CONFIGS := webpack.config.js
WEBPACK_CONFIGS_TMP := webpack_temp.config.js
WEBPACK_CONFIGS_PRO := webpack_pro.config.js
WEBPACK_DEST := public/js/index.js public/css/index.css
WEBPACK_DEST_DIRS := public/js public/css public/fonts
WEBPACK_DEST_DIRS := public/js public/css public/fonts public/img/webpack

BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
@@ -297,7 +297,7 @@ lint-frontend: node_modules

.PHONY: watch-frontend
watch-frontend: node_modules
NODE_ENV=development npx webpack --hide-modules --display-entrypoints=false --watch --progress
NODE_ENV=development npx webpack --watch --progress

.PHONY: test
test:
@@ -576,7 +576,7 @@ release-sources: | $(DIST_DIRS) node_modules
rm -f $(STORED_VERSION_FILE)

node_modules: package-lock.json
npm install --no-save
npm install --no-save --legacy-peer-deps
@touch node_modules

.PHONY: npm-update
@@ -614,7 +614,7 @@ webpack_end:

$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
rm -rf $(WEBPACK_DEST_DIRS)
npx webpack --hide-modules --display-entrypoints=false --progress
npx webpack
@touch $(WEBPACK_DEST)

.PHONY: update-translations


+ 11490
- 12768
package-lock.json
File diff suppressed because it is too large
View File


+ 14
- 12
package.json View File

@@ -1,8 +1,9 @@
{
"license": "MIT",
"private": true,
"type": "module",
"engines": {
"node": ">= 10.13.0"
"node": ">= 14.0.0"
},
"dependencies": {
"@babel/core": "7.9.6",
@@ -15,16 +16,17 @@
"babel-loader": "8.1.0",
"clipboard": "2.0.6",
"core-js": "3.6.5",
"css-loader": "3.5.3",
"css-loader": "6.7.3",
"cssnano": "4.1.10",
"dayjs": "1.10.7",
"domino": "2.1.5",
"dropzone": "5.7.2",
"echarts": "3.8.5",
"element-ui": "2.15.5",
"esbuild-loader": "2.21.0",
"esdk-obs-browserjs": "3.22.3",
"esdk-obs-nodejs": "3.20.11",
"fast-glob": "3.2.2",
"fast-glob": "3.2.12",
"file-loader": "6.0.0",
"file-saver": "2.0.5",
"fomantic-ui": "2.8.4",
@@ -35,12 +37,12 @@
"jquery-datetimepicker": "2.5.21",
"jquery.are-you-sure": "1.9.0",
"js-cookie": "3.0.1",
"less-loader": "6.1.0",
"less-loader": "11.1.0",
"mini-css-extract-plugin": "2.7.2",
"markdown-it": "13.0.1",
"mini-css-extract-plugin": "0.9.0",
"monaco-editor": "0.20.0",
"monaco-editor-webpack-plugin": "1.9.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"npm": "9.5.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.2",
@@ -48,7 +50,7 @@
"qs": "6.9.4",
"remixicon": "2.5.0",
"spark-md5": "3.0.1",
"svg-sprite-loader": "5.0.0",
"svg-sprite-loader": "6.0.11",
"svgo": "1.3.2",
"svgo-loader": "2.2.1",
"swagger-ui": "3.25.3",
@@ -58,15 +60,15 @@
"vue-bar-graph": "1.2.0",
"vue-calendar-heatmap": "0.8.4",
"vue-i18n": "6.1.3",
"vue-loader": "15.9.2",
"vue-loader": "15.10.1",
"vue-router": "3.3.4",
"vue-template-compiler": "2.6.11",
"vue-tree-list": "1.5.0",
"webpack": "4.43.0",
"webpack-cli": "3.3.12",
"webpack": "5.75.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.9.3",
"webpack-fix-style-only-entries": "0.4.0",
"worker-loader": "2.0.0",
"worker-loader": "3.0.8",
"xlsx": "0.17.3"
},
"devDependencies": {
@@ -76,10 +78,10 @@
"eslint-plugin-vue": "6.2.2",
"prettier": "2.6.2",
"script-loader": "0.7.2",
"speed-measure-webpack-plugin": "1.5.0",
"stylelint": "13.3.3",
"stylelint-config-standard": "20.0.0",
"ts-loader": "4.0.0",
"typescript": "4.5.5",
"updates": "10.2.11"
},
"scripts": {


BIN
public/0acc017d3b9b32f1f61a9af2315d5187.png View File

Before After
Width: 44  |  Height: 48  |  Size: 994 B

BIN
public/0f1600ced2415ea9530a1a55ec045fef.png View File

Before After
Width: 28  |  Height: 28  |  Size: 801 B

BIN
public/1f2e7b26b1be5e67e613178f38625008.png View File

Before After
Width: 44  |  Height: 48  |  Size: 1.0 KiB

BIN
public/276e9642cca7e5f8958c004269a6c0d7.png View File

Before After
Width: 360  |  Height: 313  |  Size: 24 KiB

BIN
public/41fa1ffe704082c381ae88ea686c9f39.png View File

Before After
Width: 44  |  Height: 20  |  Size: 567 B

BIN
public/5920c99e273bded4a2c702d4a1ed59ee.png View File

Before After
Width: 28  |  Height: 32  |  Size: 608 B

BIN
public/6f562e238482d4479212cbf367f6a293.png View File

Before After
Width: 28  |  Height: 32  |  Size: 542 B

BIN
public/71261d74041a4133ae4b9908d4a8109f.png View File

Before After
Width: 48  |  Height: 48  |  Size: 1.1 KiB

BIN
public/d4f9fbedc79f92e41f984283b6227127.png View File

Before After
Width: 48  |  Height: 48  |  Size: 1.2 KiB

+ 1
- 0
public/img/svg/icons.svg
File diff suppressed because it is too large
View File


+ 0
- 0
tsconfig.json View File


+ 2
- 3
web_src/js/components/Contributors.vue View File

@@ -51,7 +51,7 @@
<script>

const {AppSubUrl, StaticUrlPrefix, csrf} = window.config;
import LetterAvatar from '../features/letteravatar.js';
export default {

data() {
@@ -93,7 +93,6 @@ created(){
this.url = url;
let strIndex = this.url.indexOf("contributors")
this.url_code = this.url.substr(0,strIndex)

this.href_ = window.location.href;
let index = this.href_.indexOf("?")
this.url_infor = this.href_.substring(index+1,this.href_.length)
@@ -103,7 +102,7 @@ created(){

updated(){
if(document.querySelectorAll('img[avatar]').length!==0){
window.LetterAvatar.transform()
LetterAvatar.transform()
}
}
};


+ 1
- 1
web_src/js/components/EditTopics.vue View File

@@ -399,7 +399,7 @@ created(){
};
</script>

<style scoped>
<style scoped lang="less">
.input-search {
width: 100%;
display: -webkit-box;


+ 3
- 2
web_src/js/features/highlight.js View File

@@ -3,8 +3,9 @@ export default async function highlight(elementOrNodeList) {
const nodes = 'length' in elementOrNodeList ? elementOrNodeList : [elementOrNodeList];
if (!nodes.length) return;

const {default: Worker} = await import(/* webpackChunkName: "highlight" */'./highlight.worker.js');
const worker = new Worker();
const { default: Worker } = await import(/* webpackChunkName: "highlight" */'./highlight.worker.js');
// const worker = new Worker(new URL('./highlight.worker.js', import.meta.url));
const worker = new Worker();

worker.addEventListener('message', ({data}) => {
const {index, html} = data;


+ 70
- 96
web_src/js/features/letteravatar.js View File

@@ -1,100 +1,74 @@
/**
* LetterAvatar
*
* Artur Heinze
* Create Letter avatar based on Initials
* based on https://gist.github.com/leecrossley/6027780
*/
(function (w, d) {
function LetterAvatar(name, size, color) {
name = name || "";
size = size || 60;
var colours = [
"#1abc9c",
"#2ecc71",
"#3498db",
"#9b59b6",
"#34495e",
"#16a085",
"#27ae60",
"#2980b9",
"#8e44ad",
"#2c3e50",
"#f1c40f",
"#e67e22",
"#e74c3c",
"#00bcd4",
"#95a5a6",
"#f39c12",
"#d35400",
"#c0392b",
"#bdc3c7",
"#7f8c8d",
],
nameSplit = String(name).split(" "),
initials,
charIndex,
colourIndex,
canvas,
context,
dataURI;
if (nameSplit.length == 1) {
initials = nameSplit[0] ? nameSplit[0].charAt(0) : "?";
} else {
initials = nameSplit[0].charAt(0) + nameSplit[1].charAt(0);
}
let initials1 = initials.toUpperCase();
if (w.devicePixelRatio) {
size = size * w.devicePixelRatio;
}
function LetterAvatar(name, size, color) {
name = name || "";
size = size || 60;
var colours = [
"#1abc9c",
"#2ecc71",
"#3498db",
"#9b59b6",
"#34495e",
"#16a085",
"#27ae60",
"#2980b9",
"#8e44ad",
"#2c3e50",
"#f1c40f",
"#e67e22",
"#e74c3c",
"#00bcd4",
"#95a5a6",
"#f39c12",
"#d35400",
"#c0392b",
"#bdc3c7",
"#7f8c8d",
],
nameSplit = String(name).split(" "),
initials,
charIndex,
colourIndex,
canvas,
context,
dataURI;
if (nameSplit.length == 1) {
initials = nameSplit[0] ? nameSplit[0].charAt(0) : "?";
} else {
initials = nameSplit[0].charAt(0) + nameSplit[1].charAt(0);
}
let initials1 = initials.toUpperCase();
if (window.devicePixelRatio) {
size = size * window.devicePixelRatio;
}

charIndex = (initials == "?" ? 72 : initials.charCodeAt(0)) - 64;
colourIndex = charIndex % 20;
canvas = d.createElement("canvas");
canvas.width = size;
canvas.height = size;
context = canvas.getContext("2d");
charIndex = (initials == "?" ? 72 : initials.charCodeAt(0)) - 64;
colourIndex = charIndex % 20;
canvas = document.createElement("canvas");
canvas.width = size;
canvas.height = size;
context = canvas.getContext("2d");

context.fillStyle = color ? color : colours[colourIndex - 1];
context.fillRect(0, 0, canvas.width, canvas.height);
context.font = Math.round(canvas.width / 2) + "px 'Microsoft Yahei'";
context.textAlign = "center";
context.fillStyle = "#FFF";
context.fillText(initials1, size / 2, size / 1.5);
dataURI = canvas.toDataURL();
canvas = null;
return dataURI;
}
LetterAvatar.transform = function () {
Array.prototype.forEach.call(
d.querySelectorAll("img[avatar]"),
function (img, name, color) {
name = img.getAttribute("avatar");
color = img.getAttribute("color");
img.src = LetterAvatar(name, img.getAttribute("width"), color);
img.removeAttribute("avatar");
img.setAttribute("alt", name);
}
);
};
// AMD support
if (typeof define === "function" && define.amd) {
define(function () {
return LetterAvatar;
});
context.fillStyle = color ? color : colours[colourIndex - 1];
context.fillRect(0, 0, canvas.width, canvas.height);
context.font = Math.round(canvas.width / 2) + "px 'Microsoft Yahei'";
context.textAlign = "center";
context.fillStyle = "#FFF";
context.fillText(initials1, size / 2, size / 1.5);
dataURI = canvas.toDataURL();
canvas = null;
return dataURI;
}

// CommonJS and Node.js module support.
} else if (typeof exports !== "undefined") {
// Support Node.js specific `module.exports` (which can be a function)
if (typeof module != "undefined" && module.exports) {
exports = module.exports = LetterAvatar;
LetterAvatar.transform = function () {
Array.prototype.forEach.call(
document.querySelectorAll("img[avatar]"),
function (img, name, color) {
name = img.getAttribute("avatar");
color = img.getAttribute("color");
img.src = LetterAvatar(name, img.getAttribute("width"), color);
img.removeAttribute("avatar");
img.setAttribute("alt", name);
}
// But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)
exports.LetterAvatar = LetterAvatar;
} else {
window.LetterAvatar = LetterAvatar;
d.addEventListener("DOMContentLoaded", function (event) {
LetterAvatar.transform();
});
}
})(window, document);
);
};

export default LetterAvatar;

+ 0
- 1
web_src/js/index.js View File

@@ -4,7 +4,6 @@

import "./publicpath.js";
import "./polyfills.js";
import "./features/letteravatar.js";
import Vue from "vue";
import "element-ui/lib/theme-chalk/index.css";
import localeEn from 'element-ui/lib/locale/lang/en';


+ 2
- 2
web_src/vuepages/pages/ros-hmci/components/helpCollaps.vue View File

@@ -57,8 +57,8 @@ export default {
}
</script>

<style scoped>
@import url('../style/index.css');
<style scoped lang="less">
@import url('../style/index.less');

.coll_tag {
margin-top: 25px;


web_src/vuepages/pages/ros-hmci/style/index.css → web_src/vuepages/pages/ros-hmci/style/index.less View File

@@ -10,22 +10,22 @@ body {
'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
-webkit-font-smoothing : antialiased;
-moz-osx-font-smoothing: grayscale;
width : 100%;
height : 100vh;
width: 100%;
height: 100vh;
}

body * {
box-sizing : border-box;
box-sizing: border-box;
flex-shrink: 0;
}

.flex-row {
display : inline-flex;
display: inline-flex;
flex-direction: row;
}

.flex-col {
display : flex;
display: flex;
flex-direction: column;
}


+ 1
- 1
web_src/vuepages/pages/ros-hmci/vp-ros-hmci.js View File

@@ -6,7 +6,7 @@ import localeZh from 'element-ui/lib/locale/lang/zh-CN';
import { i18n, lang } from "~/langs";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './style/index.css'
import './style/index.less'





+ 120
- 140
webpack.config.js View File

@@ -1,25 +1,24 @@
const cssnano = require('cssnano');
const fastGlob = require('fast-glob');
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const PostCSSPresetEnv = require('postcss-preset-env');
const PostCSSSafeParser = require('postcss-safe-parser');
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
const TerserPlugin = require('terser-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const {statSync} = require('fs');
const {resolve, parse} = require('path');
const {SourceMapDevToolPlugin} = require('webpack');

const glob = (pattern) => fastGlob.sync(pattern, {cwd: __dirname, absolute: true});
import fastGlob from 'fast-glob';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
import {VueLoaderPlugin} from 'vue-loader';
import EsBuildLoader from 'esbuild-loader';
import {parse, dirname} from 'node:path';
import webpack from 'webpack';
import {fileURLToPath} from 'node:url';
import {readFileSync} from 'node:fs';
import TerserPlugin from "terser-webpack-plugin"
const { ESBuildMinifyPlugin } = EsBuildLoader;
const { SourceMapDevToolPlugin } = webpack;

const glob = (pattern) => fastGlob.sync(pattern, {
cwd: dirname(fileURLToPath(new URL(import.meta.url))),
absolute: true,
});
const themes = {};
for (const path of glob('web_src/less/themes/*.less')) {
themes[parse(path).name] = [path];
}

const standalone = {};
const stadalonePaths = [
...glob('web_src/js/standalone/**/*.js'),
@@ -28,14 +27,12 @@ const stadalonePaths = [
for (const path of stadalonePaths) {
standalone[parse(path).name] = [path];
}

const vuePages = {};
for (const path of glob('web_src/vuepages/**/vp-*.js')) {
vuePages[parse(path).name] = [path];
}

const isProduction = process.env.NODE_ENV !== 'development';

let isWatching = false;
for (let arg in process.argv) {
if (process.argv[arg] == '--watch') {
@@ -44,59 +41,45 @@ for (let arg in process.argv) {
}
}

module.exports = {
/** @type {import("webpack").Configuration} */
export default {
mode: isProduction ? 'production' : 'development',
entry: {
index: [
resolve(__dirname, 'web_src/js/index.js'),
resolve(__dirname, 'web_src/less/index.less'),
fileURLToPath(new URL('web_src/js/index.js', import.meta.url)),
fileURLToPath(new URL('web_src/less/index.less', import.meta.url)),
],
jquery: [
resolve(__dirname, 'web_src/js/jquery.js'),
fileURLToPath(new URL('web_src/js/jquery.js', import.meta.url)),
],
icons: glob('node_modules/@primer/octicons/build/svg/**/*.svg'),
...standalone,
...themes,
...vuePages,
...vuePages

},
devtool: false,
output: {
path: resolve(__dirname, 'public'),
filename: 'js/[name].js',
path: fileURLToPath(new URL('public', import.meta.url)),
filename: ({ chunk }) => {
// serviceworker can only manage assets below it's script's directory so
// we have to put it in / instead of /js/
return chunk.name === 'serviceworker' ? '[name].js' : 'js/[name].js';
},
chunkFilename: 'js/[name].js',
},
node:{
fs: 'empty'
},
optimization: {
minimize: false,
minimize: true,
minimizer: [
new TerserPlugin({
sourceMap: true,
extractComments: false,
terserOptions: {
keep_fnames: /^(HTML|SVG)/, // https://github.com/fgnass/domino/issues/144
output: {
comments: false,
},
},
}),
new OptimizeCSSAssetsPlugin({
cssProcessor: cssnano,
cssProcessorOptions: {
parser: PostCSSSafeParser,
},
cssProcessorPluginOptions: {
preset: [
'default',
{
discardComments: {
removeAll: true,
},
},
],
},
new ESBuildMinifyPlugin({
target: 'es2015',
minify: true,
css: true,
legalComments: 'none',
}),
// new TerserPlugin({
// extractComments: false,
// }),
],
splitChunks: {
chunks: 'async',
@@ -109,7 +92,9 @@ module.exports = {
chunks: 'async'
}
}
}
},
moduleIds: 'named',
chunkIds: 'named',
},
module: {
rules: [
@@ -118,10 +103,6 @@ module.exports = {
exclude: /node_modules/,
loader: 'vue-loader',
},
{
test: require.resolve('jquery-datetimepicker'),
use: 'imports-loader?define=>false,exports=>false',
},
{
test: /\.worker\.js$/,
exclude: /monaco/,
@@ -129,61 +110,32 @@ module.exports = {
{
loader: 'worker-loader',
options: {
name: '[name].js',
inline: true,
fallback: false,
inline: 'no-fallback',
},
},
],
},
{
test: /\.ts$/,
use: [
{
loader: "ts-loader",
}
],
exclude: /node_modules/
test: /\.m?js/,
type: "javascript/auto",
resolve: {
fullySpecified:false
}
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
loader: 'esbuild-loader',
options: {
cacheDirectory: true,
cacheCompression: false,
cacheIdentifier: [
resolve(__dirname, 'package.json'),
resolve(__dirname, 'package-lock.json'),
resolve(__dirname, 'webpack.config.js'),
].map((path) => statSync(path).mtime.getTime()).join(':'),
sourceMaps: true,
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: 3,
},
],
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
}
],
'@babel/plugin-proposal-object-rest-spread',
],
target: 'es2015'
},
},
],
},
{
test: /\.(less|css)$/i,
test: /.css$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
@@ -192,32 +144,70 @@ module.exports = {
loader: 'css-loader',
options: {
importLoaders: 2,
url: (_url, resourcePath) => {
// only resolve URLs for dependencies
url: {
filter: (url, resourcePath) => {
// only resolve URLs for dependencies
return resourcePath.includes('node_modules');
},
},
}
}
},
],
},
{
test: /.less$/i,
use: [
{
loader: 'postcss-loader',
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
plugins: () => [
PostCSSPresetEnv(),
],
sourceMap: true,
importLoaders: 2,
url: {
filter: (url, resourcePath) => {
// only resolve URLs for dependencies
return resourcePath.includes('node_modules');
},
}
},
},
{
loader: 'less-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(ttf|woff2?)$/,
type: 'asset/resource',
generator: {
filename: 'fonts/[name].[ext]',
}
},
{
test: /\.(png|jpg|gif)$/,
type: 'asset/resource',
generator: {
filename: 'img/webpack/[name].[ext]',
}
},
{
test: /\.json$/,
type: 'json',
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-sprite-loader',
options: {
extract: true,
// extract: true,
spriteFilename: 'img/svg/icons.svg',
symbolId: (path) => {
const {name} = parse(path);
@@ -233,36 +223,10 @@ module.exports = {
},
],
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader'
},
],
},
{
test: /\.(ttf|woff2?)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
publicPath: (url) => `../fonts/${url}`, // seems required for monaco's font
},
},
],
},
],
},
plugins: [
new VueLoaderPlugin(),
// avoid generating useless js output files for css- and svg-only chunks
new FixStyleOnlyEntriesPlugin({
extensions: ['less', 'scss', 'css', 'svg'],
silent: true,
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[name].css',
@@ -273,14 +237,13 @@ module.exports = {
'js/index.js',
/js\/vp-.*\.js/,
],
})] : [])
,
new SpriteLoaderPlugin({
plainSprite: true,
}),
})] : []),
new MonacoWebpackPlugin({
filename: 'js/monaco-[name].worker.js',
})
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}),
],
performance: {
hints: false,
@@ -291,9 +254,9 @@ module.exports = {
symlinks: false,
alias: {
vue$: 'vue/dist/vue.esm.js', // needed because vue's default export is the runtime only
'~': resolve(__dirname, 'web_src/vuepages'),
'~': fileURLToPath(new URL('web_src/vuepages', import.meta.url))
},
extensions: ['.tsx', '.ts', '.js']
extensions: ['.vue', '.ts', '.js']
},
watchOptions: {
ignored: [
@@ -301,6 +264,23 @@ module.exports = {
],
},
stats: {
assetsSort: 'name',
assetsSpace: Infinity,
cached: false,
cachedModules: false,
children: false,
chunkModules: false,
chunkOrigins: false,
chunksSort: 'name',
colors: true,
entrypoints: false,
groupAssetsByChunk: false,
groupAssetsByEmitStatus: false,
groupAssetsByInfo: false,
groupModulesByAttributes: false,
modules: false,
reasons: false,
runtimeModules: false,
},
};

+ 115
- 135
webpack_pro.config.js View File

@@ -1,25 +1,24 @@
const cssnano = require('cssnano');
const fastGlob = require('fast-glob');
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const PostCSSPresetEnv = require('postcss-preset-env');
const PostCSSSafeParser = require('postcss-safe-parser');
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
const TerserPlugin = require('terser-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const {statSync} = require('fs');
const {resolve, parse} = require('path');
//const {SourceMapDevToolPlugin} = require('webpack');

const glob = (pattern) => fastGlob.sync(pattern, {cwd: __dirname, absolute: true});
import fastGlob from 'fast-glob';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
import {VueLoaderPlugin} from 'vue-loader';
import EsBuildLoader from 'esbuild-loader';
import {parse, dirname} from 'node:path';
import webpack from 'webpack';
import {fileURLToPath} from 'node:url';
import {readFileSync} from 'node:fs';
import TerserPlugin from "terser-webpack-plugin"
const { ESBuildMinifyPlugin } = EsBuildLoader;
const { SourceMapDevToolPlugin } = webpack;

const glob = (pattern) => fastGlob.sync(pattern, {
cwd: dirname(fileURLToPath(new URL(import.meta.url))),
absolute: true,
});
const themes = {};
for (const path of glob('web_src/less/themes/*.less')) {
themes[parse(path).name] = [path];
}

const standalone = {};
const stadalonePaths = [
...glob('web_src/js/standalone/**/*.js'),
@@ -28,7 +27,6 @@ const stadalonePaths = [
for (const path of stadalonePaths) {
standalone[parse(path).name] = [path];
}

const vuePages = {};
for (const path of glob('web_src/vuepages/**/vp-*.js')) {
vuePages[parse(path).name] = [path];
@@ -36,58 +34,42 @@ for (const path of glob('web_src/vuepages/**/vp-*.js')) {

const isProduction = process.env.NODE_ENV !== 'development';

module.exports = {

/** @type {import("webpack").Configuration} */
export default {
mode: isProduction ? 'production' : 'development',
entry: {
index: [
resolve(__dirname, 'web_src/js/index.js'),
resolve(__dirname, 'web_src/less/index.less'),
fileURLToPath(new URL('web_src/js/index.js', import.meta.url)),
fileURLToPath(new URL('web_src/less/index.less', import.meta.url)),
],
jquery: [
resolve(__dirname, 'web_src/js/jquery.js'),
fileURLToPath(new URL('web_src/js/jquery.js', import.meta.url)),
],
icons: glob('node_modules/@primer/octicons/build/svg/**/*.svg'),
...standalone,
...themes,
...vuePages

},
devtool: false,
output: {
path: resolve(__dirname, 'public'),
filename: 'js/[name].js',
path: fileURLToPath(new URL('public', import.meta.url)),
filename: ({ chunk }) => {
// serviceworker can only manage assets below it's script's directory so
// we have to put it in / instead of /js/
return chunk.name === 'serviceworker' ? '[name].js' : 'js/[name].js';
},
chunkFilename: 'js/[name].js',
},
node:{
fs: 'empty'
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
sourceMap: false,
extractComments: false,
terserOptions: {
keep_fnames: /^(HTML|SVG)/, // https://github.com/fgnass/domino/issues/144
output: {
comments: false,
},
},
}),
new OptimizeCSSAssetsPlugin({
cssProcessor: cssnano,
cssProcessorOptions: {
parser: PostCSSSafeParser,
},
cssProcessorPluginOptions: {
preset: [
'default',
{
discardComments: {
removeAll: true,
},
},
],
},
new ESBuildMinifyPlugin({
target: 'es2015',
minify: true,
css: true,
legalComments: 'none',
}),
],
splitChunks: {
@@ -101,7 +83,9 @@ module.exports = {
chunks: 'async'
}
}
}
},
moduleIds: 'named',
chunkIds: 'named',
},
module: {
rules: [
@@ -110,10 +94,6 @@ module.exports = {
exclude: /node_modules/,
loader: 'vue-loader',
},
{
test: require.resolve('jquery-datetimepicker'),
use: 'imports-loader?define=>false,exports=>false',
},
{
test: /\.worker\.js$/,
exclude: /monaco/,
@@ -121,61 +101,32 @@ module.exports = {
{
loader: 'worker-loader',
options: {
name: '[name].js',
inline: true,
fallback: false,
inline: 'no-fallback',
},
},
],
},
{
test: /\.ts$/,
use: [
{
loader: "ts-loader",
}
],
exclude: /node_modules/
test: /\.m?js/,
type: "javascript/auto",
resolve: {
fullySpecified:false
}
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
loader: 'esbuild-loader',
options: {
cacheDirectory: true,
cacheCompression: false,
cacheIdentifier: [
resolve(__dirname, 'package.json'),
resolve(__dirname, 'package-lock.json'),
resolve(__dirname, 'webpack.config.js'),
].map((path) => statSync(path).mtime.getTime()).join(':'),
sourceMaps: true,
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: 3,
},
],
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
}
],
'@babel/plugin-proposal-object-rest-spread',
],
target: 'es2015'
},
},
],
},
{
test: /\.(less|css)$/i,
test: /.css$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
@@ -184,32 +135,70 @@ module.exports = {
loader: 'css-loader',
options: {
importLoaders: 2,
url: (_url, resourcePath) => {
// only resolve URLs for dependencies
url: {
filter: (url, resourcePath) => {
// only resolve URLs for dependencies
return resourcePath.includes('node_modules');
},
},
}
}
},
],
},
{
test: /.less$/i,
use: [
{
loader: 'postcss-loader',
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
plugins: () => [
PostCSSPresetEnv(),
],
sourceMap: true,
importLoaders: 2,
url: {
filter: (url, resourcePath) => {
// only resolve URLs for dependencies
return resourcePath.includes('node_modules');
},
}
},
},
{
loader: 'less-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(ttf|woff2?)$/,
type: 'asset/resource',
generator: {
filename: 'fonts/[name].[ext]',
}
},
{
test: /\.(png|jpg|gif)$/,
type: 'asset/resource',
generator: {
filename: 'img/webpack/[name].[ext]',
}
},
{
test: /\.json$/,
type: 'json',
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-sprite-loader',
options: {
extract: true,
// extract: true,
spriteFilename: 'img/svg/icons.svg',
symbolId: (path) => {
const {name} = parse(path);
@@ -225,46 +214,20 @@ module.exports = {
},
],
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader'
},
],
},
{
test: /\.(ttf|woff2?)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
publicPath: (url) => `../fonts/${url}`, // seems required for monaco's font
},
},
],
},
],
},
plugins: [
new VueLoaderPlugin(),
// avoid generating useless js output files for css- and svg-only chunks
new FixStyleOnlyEntriesPlugin({
extensions: ['less', 'scss', 'css', 'svg'],
silent: true,
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[name].css',
}),
new SpriteLoaderPlugin({
plainSprite: true,
}),
new MonacoWebpackPlugin({
filename: 'js/monaco-[name].worker.js',
})
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}),
],
performance: {
hints: false,
@@ -275,9 +238,9 @@ module.exports = {
symlinks: false,
alias: {
vue$: 'vue/dist/vue.esm.js', // needed because vue's default export is the runtime only
'~': resolve(__dirname, 'web_src/vuepages'),
'~': fileURLToPath(new URL('web_src/vuepages', import.meta.url))
},
extensions: ['.tsx', '.ts', '.js']
extensions: ['.vue', '.ts', '.js']
},
watchOptions: {
ignored: [
@@ -285,6 +248,23 @@ module.exports = {
],
},
stats: {
assetsSort: 'name',
assetsSpace: Infinity,
cached: false,
cachedModules: false,
children: false,
chunkModules: false,
chunkOrigins: false,
chunksSort: 'name',
colors: true,
entrypoints: false,
groupAssetsByChunk: false,
groupAssetsByEmitStatus: false,
groupAssetsByInfo: false,
groupModulesByAttributes: false,
modules: false,
reasons: false,
runtimeModules: false,
},
};

+ 1790
- 2721
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save