diff --git a/package.json b/package.json index b6819952b9..2c46be02f6 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,7 @@ "copy:i18n": "mkdir -p ./build/shared/i18n && cp -R ./shared/i18n/locales ./build/shared/i18n", "build:i18n": "i18next --silent 'shared/**/*.tsx' 'shared/**/*.ts' 'app/**/*.tsx' 'app/**/*.ts' 'server/**/*.ts' 'server/**/*.tsx' && yarn copy:i18n", "build:server": "./build.sh", - "build:webpack": "webpack --config webpack.config.prod.js", - "build": "yarn build:webpack && yarn build:i18n && yarn build:server", + "build": "yarn vite:build && yarn build:i18n && yarn build:server", "start": "node ./build/server/index.js", "dev": "NODE_ENV=development yarn concurrently -n api,frontend,collaboration -c \"blue,magenta\" \"node --inspect=0.0.0.0 build/server/index.js --services=collaboration,websockets,admin,web,worker\" \"yarn vite:dev\"", "dev:watch": "nodemon --exec \"yarn build:server && yarn dev\" -e js,ts,tsx --ignore build/ --ignore app/ --ignore shared/editor", @@ -17,7 +16,7 @@ "deploy": "git push heroku master", "prepare": "husky install", "postinstall": "rimraf node_modules/prosemirror-view/dist/index.d.ts && patch-package", - "heroku-postbuild": "yarn build:webpack && yarn build:server && yarn copy:i18n && yarn db:migrate", + "heroku-postbuild": "yarn vite:build && yarn build:server && yarn copy:i18n && yarn db:migrate", "sequelize:migrate": "sequelize db:migrate", "db:create-migration": "sequelize migration:create", "db:create": "sequelize db:create", @@ -234,7 +233,6 @@ "@babel/cli": "^7.10.5", "@babel/preset-typescript": "^7.16.0", "@getoutline/jest-runner-serial": "^2.0.0", - "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10", "@relative-ci/agent": "^3.0.0", "@types/body-scroll-lock": "^3.1.0", "@types/crypto-js": "^4.1.1", @@ -329,14 +327,11 @@ "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4.1.0", "fetch-test-server": "^1.1.0", - "html-webpack-plugin": "4.5.2", "husky": "^8.0.2", "i18next-parser": "^7.1.0", "jest-cli": "^28.1.3", "jest-environment-jsdom": "^28.1.3", "jest-fetch-mock": "^3.0.3", - "koa-webpack-dev-middleware": "^1.4.5", - "koa-webpack-hot-middleware": "^1.0.3", "lint-staged": "^12.3.8", "nodemon": "^2.0.20", "patch-package": "^6.5.1", @@ -344,17 +339,10 @@ "prettier": "^2.0.5", "react-refresh": "^0.14.0", "rimraf": "^2.5.4", - "rollup-plugin-webpack-stats": "^0.0.4", "style-loader": "2.0.0", - "terser-webpack-plugin": "^4.1.0", "typescript": "^4.7.4", "url-loader": "^4.1.1", "vite-plugin-pwa": "^0.14.1", - "webpack": "4.46.0", - "webpack-cli": "^4.10.0", - "webpack-manifest-plugin": "^3.0.0", - "webpack-pwa-manifest": "^4.3.0", - "workbox-webpack-plugin": "^6.5.3", "yarn-deduplicate": "^6.0.1" }, "resolutions": { diff --git a/webpack.config.dev.js b/webpack.config.dev.js deleted file mode 100644 index ace46dcf49..0000000000 --- a/webpack.config.dev.js +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-disable */ -const webpack = require("webpack"); -const commonWebpackConfig = require("./webpack.config"); -const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); - -const isTest = process.env.NODE_ENV === "test"; - -const developmentWebpackConfig = Object.assign(commonWebpackConfig, { - cache: true, - mode: "development", - devtool: "eval-cheap-module-source-map", - entry: [ - "webpack-hot-middleware/client", - "./app/index", - ], - optimization: { - usedExports: true, - }, -}); - -if (!isTest) { - developmentWebpackConfig.plugins = [ - ...developmentWebpackConfig.plugins, - new webpack.HotModuleReplacementPlugin(), - new ReactRefreshWebpackPlugin({ - overlay: { - sockIntegration: 'whm', - }, - }), - ]; -} - -module.exports = developmentWebpackConfig; diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index fe82783302..0000000000 --- a/webpack.config.js +++ /dev/null @@ -1,122 +0,0 @@ -/* eslint-disable */ -const path = require('path'); -const webpack = require('webpack'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const { RelativeCiAgentWebpackPlugin } = require('@relative-ci/agent'); -const WebpackPwaManifest = require("webpack-pwa-manifest"); -const WorkboxPlugin = require("workbox-webpack-plugin"); - -require('dotenv').config({ silent: true }); - -module.exports = { - output: { - path: path.join(__dirname, 'build/app'), - filename: '[name].[hash].js', - publicPath: '/static/', - }, - module: { - rules: [ - { - test: /\.[jt]sx?$/, - loader: 'babel-loader', - exclude: [ - path.join(__dirname, 'node_modules') - ], - include: [ - path.join(__dirname, 'app'), - path.join(__dirname, 'shared'), - ], - options: { - cacheDirectory: true - } - }, - // inline base64 URLs for <=8k images, direct URLs for the rest - { test: /\.(png|jpg|svg)$/, loader: 'url-loader' }, - { - test: /\.(woff|woff2|ttf|eot)$/, - loader: - 'url-loader?limit=1&mimetype=application/font-woff&name=public/fonts/[name].[ext]', - }, - { test: /\.md/, loader: 'raw-loader' }, - { - test: /\.css$/i, - use: ['style-loader', 'css-loader'], - }, - ], - }, - resolve: { - extensions: ['.ts', '.tsx', '.js', '.json'], - modules: [ - path.resolve(__dirname, 'app'), - 'node_modules' - ], - alias: { - "~": path.resolve(__dirname, 'app'), - "@shared": path.resolve(__dirname, 'shared'), - "@server": path.resolve(__dirname, 'server'), - 'boundless-popover': 'boundless-popover/build', - 'boundless-utils-omit-keys': 'boundless-utils-omit-keys/build', - 'boundless-utils-uuid': 'boundless-utils-uuid/build' - } - }, - plugins: [ - new webpack.IgnorePlugin(/unicode\/category\/So/), - new HtmlWebpackPlugin({ - template: 'server/static/index.html', - }), - new WebpackPwaManifest({ - name: "Outline", - short_name: "Outline", - background_color: "#fff", - theme_color: "#fff", - start_url: "/", - publicPath: "/static/", - display: "standalone", - icons: [ - { - src: path.resolve("public/images/icon-512.png"), - // For Chrome, you must provide at least a 192x192 pixel icon, and a 512x512 pixel icon. - // If only those two icon sizes are provided, Chrome will automatically scale the icons - // to fit the device. If you'd prefer to scale your own icons, and adjust them for - // pixel-perfection, provide icons in increments of 48dp. - sizes: [512, 192], - purpose: "any maskable", - }, - ] - }), - new WorkboxPlugin.GenerateSW({ - clientsClaim: true, - skipWaiting: true, - maximumFileSizeToCacheInBytes: 15 * 1024 * 1024, // For large bundles - }), - new RelativeCiAgentWebpackPlugin(), - ], - stats: { - assets: false, - }, - optimization: { - runtimeChunk: 'single', - moduleIds: 'hashed', - chunkIds: 'named', - splitChunks: { - chunks: 'async', - minSize: 20000, - minChunks: 1, - maxAsyncRequests: 30, - maxInitialRequests: 30, - enforceSizeThreshold: 50000, - cacheGroups: { - defaultVendors: { - test: /[\\/]node_modules[\\/]/, - priority: -10, - reuseExistingChunk: true, - }, - default: { - minChunks: 2, - priority: -20, - reuseExistingChunk: true, - } - } - } - } -}; diff --git a/webpack.config.prod.js b/webpack.config.prod.js deleted file mode 100644 index 60a285b6c8..0000000000 --- a/webpack.config.prod.js +++ /dev/null @@ -1,48 +0,0 @@ -/* eslint-disable */ -const path = require('path'); -const webpack = require('webpack'); -const { WebpackManifestPlugin } = require('webpack-manifest-plugin'); -const TerserPlugin = require('terser-webpack-plugin'); - -commonWebpackConfig = require('./webpack.config'); - -productionWebpackConfig = Object.assign(commonWebpackConfig, { - output: { - path: path.join(__dirname, 'build/app'), - filename: '[name].[contenthash].js', - publicPath: `${process.env.CDN_URL || ""}/static/`, - }, - cache: true, - mode: "production", - devtool: 'source-map', - entry: ['./app/index'], - stats: "normal", - optimization: { - ...commonWebpackConfig.optimization, - minimizer: [ - new TerserPlugin({ - terserOptions: { - ecma: undefined, - parse: {}, - compress: {}, - mangle: true, // Note `mangle.properties` is `false` by default. - module: false, - output: null, - toplevel: false, - nameCache: null, - ie8: false, - keep_classnames: undefined, - keep_fnames: true, - safari10: false, - }, - }), - ], - }, -}); - -productionWebpackConfig.plugins = [ - ...productionWebpackConfig.plugins, - new WebpackManifestPlugin() -]; - -module.exports = productionWebpackConfig;