aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package-lock.json24
-rw-r--r--package.json5
-rw-r--r--vnext/server/webpack.config.js74
3 files changed, 101 insertions, 2 deletions
diff --git a/package-lock.json b/package-lock.json
index a77aca9e..5f8b5333 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -46,6 +46,7 @@
"autoprefixer": "^10.4.13",
"babel-loader": "^9.1.2",
"core-js": "^3.29.0",
+ "cors": "^2.8.5",
"cross-env": "^7.0.3",
"css-loader": "^6.7.3",
"cssnano": "^5.1.15",
@@ -6406,6 +6407,19 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
+ "node_modules/cors": {
+ "version": "2.8.5",
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
+ "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
+ "dev": true,
+ "dependencies": {
+ "object-assign": "^4",
+ "vary": "^1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
"node_modules/cosmiconfig": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.0.0.tgz",
@@ -22776,6 +22790,16 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
+ "cors": {
+ "version": "2.8.5",
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
+ "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
+ "dev": true,
+ "requires": {
+ "object-assign": "^4",
+ "vary": "^1"
+ }
+ },
"cosmiconfig": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.0.0.tgz",
diff --git a/package.json b/package.json
index 89ca19b3..15619434 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,8 @@
"lint": "eslint .",
"vnext:test": "jest",
"vnext:build": "webpack -c vnext/webpack.config.js",
- "vnext:build:ssr": "npm run vnext:build && esbuild --bundle --sourcemap --minify --keep-names --platform=node --target=node18 --loader:.js=jsx --loader:.png=file --loader:.svg=file --outfile=public/server.js vnext/server/index.js",
- "vnext:start-ssr": "npm run vnext:build:ssr && cross-env DEBUG=http node public/server.js",
+ "vnext:build:ssr": "npm run vnext:build && webpack -c vnext/server/webpack.config.js",
+ "vnext:start-ssr": "npm run vnext:build:ssr && cross-env DEBUG=http node --enable-source-maps public/server.js",
"vnext:start": "cross-env NODE_ENV=development webpack serve -c vnext/webpack.config.js --mode development",
"vnext:lint": "eslint vnext/src/**/*.js"
},
@@ -50,6 +50,7 @@
"autoprefixer": "^10.4.13",
"babel-loader": "^9.1.2",
"core-js": "^3.29.0",
+ "cors": "^2.8.5",
"cross-env": "^7.0.3",
"css-loader": "^6.7.3",
"cssnano": "^5.1.15",
diff --git a/vnext/server/webpack.config.js b/vnext/server/webpack.config.js
new file mode 100644
index 00000000..a58f858c
--- /dev/null
+++ b/vnext/server/webpack.config.js
@@ -0,0 +1,74 @@
+/* eslint-disable @typescript-eslint/no-var-requires */
+
+const ESLintPlugin = require('eslint-webpack-plugin');
+const TerserPlugin = require('terser-webpack-plugin');
+
+module.exports = (env, argv) => {
+ const node_env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
+ const dev = node_env !== 'production';
+ const config = {
+ mode: node_env,
+ devtool: dev ? 'cheap-module-source-map' : false,
+ entry: {
+ 'server': [
+ __dirname + '/index.js'
+ ]
+ },
+ target: 'node',
+ output: {
+ path: __dirname + '/../../public',
+ filename: '[name].js'
+ },
+ module: {
+ rules: [{
+ test: /\.js$/,
+ exclude: [
+ /node_modules/
+ ],
+ loader: 'babel-loader'
+ }, {
+ test: /\.(png|jpe?g|gif|svg)$/i,
+ use: [
+ {
+ loader: 'file-loader',
+ },
+ ],
+ }]
+ },
+ plugins: [
+ ],
+ resolve: {
+ symlinks: false,
+ extensions: ['.js']
+ }
+ };
+ if (dev) {
+ config.plugins.push(
+ new ESLintPlugin({
+ files: __dirname + '/src',
+ lintDirtyModulesOnly: true,
+ failOnWarning: false,
+ failOnError: true,
+ fix: false
+ }));
+ config.devServer = {
+ hot: true,
+ historyApiFallback: true,
+ client: {
+ overlay: true
+ }
+ };
+ }
+ config.optimization = {
+ minimize: !dev,
+ minimizer: [
+ new TerserPlugin({
+ minify: TerserPlugin.swcMinify,
+ // `terserOptions` options will be passed to `swc` (`@swc/core`)
+ // Link to options - https://swc.rs/docs/config-js-minify
+ terserOptions: {},
+ }),
+ ]
+ };
+ return config;
+};