diff --git a/build/build.js b/build/build.mjs similarity index 79% rename from build/build.js rename to build/build.mjs index 34c71a55..2dd1886b 100644 --- a/build/build.js +++ b/build/build.mjs @@ -1,15 +1,16 @@ 'use strict' -require('./check-versions')() +import checkVersions from './check-versions.mjs' +checkVersions() -const ora = require('ora') -const rm = require('rimraf') -const path = require('path') -const chalk = require('chalk') -const webpack = require('webpack') -const config = require('../config') -const webpackConfig = require('./webpack.prod.conf') -var connect = require('connect') -var serveStatic = require('serve-static') +import ora from 'ora' +import rm from 'rimraf' +import path from 'path' +import chalk from 'chalk' +import webpack from 'webpack' +import config from '../config/index.js' +import webpackConfig from './webpack.prod.conf.js' +import connect from 'connect' +import serveStatic from 'serve-static' const spinner = ora( 'building for ' + process.env.env_config + ' environment...' diff --git a/build/check-versions.js b/build/check-versions.mjs similarity index 82% rename from build/check-versions.js rename to build/check-versions.mjs index c5c29e90..239475e9 100644 --- a/build/check-versions.js +++ b/build/check-versions.mjs @@ -1,11 +1,12 @@ 'use strict' -const chalk = require('chalk') -const semver = require('semver') -const packageConfig = require('../package.json') -const shell = require('shelljs') +import chalk from 'chalk' +import semver from 'semver' +import packageConfig from '../package.json' assert {type: "json"} +import shell from 'shelljs' +import childProcess from 'child_process' function exec(cmd) { - return require('child_process') + return childProcess .execSync(cmd) .toString() .trim() @@ -27,7 +28,7 @@ if (shell.which('npm')) { }) } -module.exports = function() { +export default function() { const warnings = [] for (let i = 0; i < versionRequirements.length; i++) { diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 3c8975e3..4de456d2 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -4,6 +4,7 @@ const utils = require('./utils') const config = require('../config') const { VueLoaderPlugin } = require('vue-loader') const vueLoaderConfig = require('./vue-loader.conf') +const NodePolyfillPlugin = require("node-polyfill-webpack-plugin") function resolve(dir) { return path.join(__dirname, '..', dir) @@ -41,7 +42,6 @@ module.exports = { }, module: { rules: [ - ...(config.dev.useEslint ? [createLintingRule()] : []), { test: /\.vue$/, loader: 'vue-loader', @@ -49,7 +49,10 @@ module.exports = { }, { test: /\.js$/, - loader: 'babel-loader?cacheDirectory', + loader: 'babel-loader', + options: { + cacheDirectory: true + }, include: [ resolve('src'), resolve('test'), @@ -90,17 +93,5 @@ module.exports = { } ] }, - plugins: [new VueLoaderPlugin()], - node: { - // prevent webpack from injecting useless setImmediate polyfill because Vue - // source contains it (although only uses it if it's native). - setImmediate: false, - // prevent webpack from injecting mocks to Node native modules - // that does not make sense for the client - dgram: 'empty', - fs: 'empty', - net: 'empty', - tls: 'empty', - child_process: 'empty' - } + plugins: [new VueLoaderPlugin(), new NodePolyfillPlugin()], } diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 1b6d4d75..28a909bd 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -6,7 +6,6 @@ const config = require('../config') const merge = require('webpack-merge') const baseWebpackConfig = require('./webpack.base.conf') const HtmlWebpackPlugin = require('html-webpack-plugin') -const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') const portfinder = require('portfinder') function resolve(dir) { @@ -43,7 +42,6 @@ const devWebpackConfig = merge(baseWebpackConfig, { : false, publicPath: devEnv.ASSETS_PUBLIC_PATH, proxy: config.dev.proxyTable, - quiet: true, // necessary for FriendlyErrorsPlugin watchOptions: { poll: config.dev.poll }, @@ -81,22 +79,6 @@ module.exports = new Promise((resolve, reject) => { // add port to devServer config devWebpackConfig.devServer.port = port - // Add FriendlyErrorsPlugin - devWebpackConfig.plugins.push( - new FriendlyErrorsPlugin({ - compilationSuccessInfo: { - messages: [ - `Your application is running here: http://${ - devWebpackConfig.devServer.host - }:${port}` - ] - }, - onErrors: config.dev.notifyOnErrors - ? utils.createNotifierCallback() - : undefined - }) - ) - resolve(devWebpackConfig) } }) diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 018a2f62..ec56b04f 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -3,14 +3,12 @@ const path = require('path') const utils = require('./utils') const webpack = require('webpack') const config = require('../config') -const merge = require('webpack-merge') +const {merge} = require('webpack-merge') const baseWebpackConfig = require('./webpack.base.conf') const CopyWebpackPlugin = require('copy-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') -const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') -const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') -const UglifyJsPlugin = require('uglifyjs-webpack-plugin') +const CssMinimizerPlugin = require('css-minimizer-webpack-plugin') function resolve(dir) { return path.join(__dirname, '..', dir) @@ -70,35 +68,19 @@ const webpackConfig = merge(baseWebpackConfig, { // in certain cases, and in webpack 4, chunk order in HTML doesn't // matter anyway }), - // keep chunk.id stable when chunk has no name - new webpack.NamedChunksPlugin(chunk => { - if (chunk.name) { - return chunk.name - } - const modules = Array.from(chunk.modulesIterable) - if (modules.length > 1) { - const hash = require('hash-sum') - const joinedHash = hash(modules.map(m => m.id).join('_')) - let len = nameLength - while (seen.has(joinedHash.substr(0, len))) len++ - seen.add(joinedHash.substr(0, len)) - return `chunk-${joinedHash.substr(0, len)}` - } else { - return modules[0].id - } - }), - // keep module.id stable when vender modules does not change - new webpack.HashedModuleIdsPlugin(), // copy custom static assets - new CopyWebpackPlugin([ + new CopyWebpackPlugin({ patterns: [ { from: path.resolve(__dirname, '../static'), to: config.build.assetsSubDirectory, - ignore: ['.*'] + globOptions: { + dot: true + } } - ]) + ]}) ], optimization: { + minimize: true, splitChunks: { chunks: 'all', cacheGroups: { @@ -124,19 +106,9 @@ const webpackConfig = merge(baseWebpackConfig, { }, runtimeChunk: 'single', minimizer: [ - new UglifyJsPlugin({ - uglifyOptions: { - mangle: { - safari10: true - } - }, - sourceMap: config.build.productionSourceMap, - cache: true, - parallel: true - }), // Compress extracted CSS. We are using this plugin so that possible // duplicated CSS from different components can be deduped. - new OptimizeCSSAssetsPlugin() + new CssMinimizerPlugin() ] } }) diff --git a/package.json b/package.json index f267be19..62900f10 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "license": "MIT", "scripts": { "dev": "cross-env BABEL_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", - "build:prod": "cross-env NODE_ENV=production env_config=prod node build/build.js", - "build:sit": "cross-env NODE_ENV=production env_config=sit node build/build.js", + "build:prod": "cross-env NODE_ENV=production env_config=prod node build/build.mjs", + "build:sit": "cross-env NODE_ENV=production env_config=sit node build/build.mjs", "lint": "eslint --ext .js,.vue src", "test": "jest", "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand", @@ -31,49 +31,46 @@ "type": "git", "url": "git+https://akkoma.dev/AkkomaGang/admin-fe.git" }, - "resolutions": { - "prosemirror-model": "1.9.1" - }, "bugs": { "url": "https://akkoma.dev/AkkomaGang/admin-fe/-/issues" }, "dependencies": { "@babel/runtime": "^7.3.4", - "axios": "0.18.0", - "clipboard": "1.7.1", - "codemirror": "5.39.2", - "default-passive-events": "^1.0.10", - "driver.js": "0.8.1", - "dropzone": "5.2.0", - "echarts": "4.1.0", + "@toast-ui/editor": "^3.2.0", + "axios": "^0.27.2", + "clipboard": "^2.0.11", + "codemirror": "^6.0.1", + "default-passive-events": "^2.0.0", + "driver.js": "^0.9.8", + "dropzone": "^6.0.0-beta.2", + "echarts": "^5.3.3", "element-ui": "^2.13.0", - "file-saver": "1.3.8", - "fuse.js": "3.4.2", - "js-cookie": "2.2.0", - "jsonlint": "1.6.3", - "jszip": "3.1.5", + "file-saver": "^2.0.5", + "fuse.js": "^6.6.2", + "js-cookie": "^3.0.1", + "jsonlint": "^1.6.3", + "jszip": "^3.1.5", "localforage": "^1.7.3", "lodash": "^4.17.11", "lodash.debounce": "^4.0.8", - "marked": "^0.8.0", + "marked": "^4.1.0", "moment": "^2.24.0", - "normalize.css": "7.0.0", - "nprogress": "0.2.0", + "normalize.css": "^8.0.1", + "nprogress": "^0.2.0", "numeral": "^2.0.6", - "screenfull": "4.0.0", - "showdown": "1.8.6", - "sortablejs": "1.7.0", + "screenfull": "^6.0.2", + "showdown": "^2.1.0", + "sortablejs": "^1.7.0", "tiptap": "^1.29.6", "tiptap-extensions": "^1.32.7", - "tui-editor": "1.2.7", "vue": "^2.6.8", - "vue-count-to": "1.0.13", - "vue-i18n": "^8.9.0", + "vue-count-to": "^1.0.13", + "vue-i18n": "^8", "vue-router": "^3.5.1", - "vue-splitpane": "1.0.2", + "vue-splitpane": "^1.0.2", "vuedraggable": "^2.16.0", - "vuex": "3.0.1", - "xlsx": "^0.11.16" + "vuex": "^3.0.1", + "xlsx": "^0.18.5" }, "devDependencies": { "@babel/core": "^7.3.4", @@ -82,62 +79,60 @@ "@babel/preset-env": "^7.3.4", "@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.2", "@vue/babel-preset-jsx": "^1.0.0-beta.2", - "@vue/test-utils": "^1.1.0", - "autoprefixer": "8.5.0", - "babel-eslint": "8.2.6", - "babel-helper-vue-jsx-merge-props": "2.0.3", - "babel-jest": "^25.3.0", + "@vue/test-utils": "^1", + "autoprefixer": "^10.4.11", + "babel-eslint": "^10.1.0", + "babel-helper-vue-jsx-merge-props": "^2.0.3", + "babel-jest": "^26", "babel-loader": "^8.0.5", "babel-plugin-dynamic-import-node-babel-7": "^2.0.7", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", - "chalk": "2.4.1", - "compression-webpack-plugin": "2.0.0", - "connect": "3.6.6", - "copy-webpack-plugin": "4.5.2", - "cross-env": "5.2.0", - "css-loader": "1.0.0", - "eslint": "4.19.1", - "eslint-friendly-formatter": "4.0.1", - "eslint-loader": "2.0.0", - "eslint-plugin-vue": "4.7.1", - "file-loader": "1.1.11", + "chalk": "^5.0.1", + "compression-webpack-plugin": "^10.0.0", + "connect": "^3.6.6", + "copy-webpack-plugin": "^11.0.0", + "cross-env": "^7.0.3", + "css-loader": "^6.7.1", + "css-minimizer-webpack-plugin": "^4.1.0", + "eslint": "^7", + "eslint-friendly-formatter": "^4.0.1", + "eslint-loader": "^4.0.2", + "eslint-plugin-vue": "^9.4.0", + "file-loader": "^6.2.0", "flush-promises": "^1.0.2", - "friendly-errors-webpack-plugin": "1.7.0", - "hash-sum": "1.0.2", - "html-webpack-plugin": "^3.2.0", - "husky": "0.14.3", - "jest": "^25.3.0", + "hash-sum": "^2.0.0", + "html-webpack-plugin": "^5.5.0", + "husky": "^8.0.1", + "jest": "^26", "jest-transform-stub": "^2.0.0", - "lint-staged": "7.2.2", - "mini-css-extract-plugin": "0.4.1", - "node-notifier": "5.2.1", + "lint-staged": "^13.0.3", + "mini-css-extract-plugin": "^2.6.1", + "node-notifier": "^10.0.1", + "node-polyfill-webpack-plugin": "^2.0.1", "node-sass": "^7.0.1", - "optimize-css-assets-webpack-plugin": "5.0.0", - "ora": "3.0.0", - "path-to-regexp": "2.4.0", - "portfinder": "1.0.13", - "postcss-loader": "2.1.6", - "postcss-url": "7.3.2", - "rimraf": "2.6.2", - "sass-loader": "7.0.3", - "script-ext-html-webpack-plugin": "2.0.1", - "script-loader": "0.7.2", - "semver": "5.5.0", - "serve-static": "1.13.2", - "shelljs": "0.8.2", - "svg-sprite-loader": "3.8.0", - "svgo": "1.0.5", - "uglifyjs-webpack-plugin": "1.2.7", - "url-loader": "1.0.1", - "vue-jest": "4.0.0-beta.2", - "vue-loader": "15.3.0", - "vue-style-loader": "4.1.2", + "ora": "^6.1.2", + "path-to-regexp": "^6.2.1", + "portfinder": "^1.0.13", + "postcss-loader": "^7.0.1", + "postcss-url": "^10.1.3", + "rimraf": "^3.0.2", + "sass-loader": "^13.0.2", + "script-loader": "^0.7.2", + "semver": "^7.3.7", + "serve-static": "^1.13.2", + "shelljs": "^0.8.2", + "svg-sprite-loader": "^6.0.11", + "svgo": "^2.8.0", + "url-loader": "^4.1.1", + "vue-jest": "^4.0.0-beta.2", + "vue-loader": "^15.0.0", + "vue-style-loader": "^4.1.2", "vue-template-compiler": "^2.6.8", - "webpack": "^4.29.6", - "webpack-bundle-analyzer": "2.13.1", - "webpack-cli": "^3.2.3", - "webpack-dev-server": "3.11.0", - "webpack-merge": "4.1.4" + "webpack": "^5.74.0", + "webpack-bundle-analyzer": "^4.6.1", + "webpack-cli": "^4.10.0", + "webpack-dev-server": "^4.11.0", + "webpack-merge": "^5.8.0" }, "engines": { "node": ">= 6.0.0", diff --git a/src/components/element-ui/MarkdownEditor/index.vue b/src/components/element-ui/MarkdownEditor/index.vue index 7ae9fd40..18114701 100644 --- a/src/components/element-ui/MarkdownEditor/index.vue +++ b/src/components/element-ui/MarkdownEditor/index.vue @@ -5,10 +5,10 @@