Projects STRLCPY gradejs Commits 7c7a38fb
🤬
  • ■ ■ ■ ■ ■
    packages/web/package.json
    skipped 7 lines
    8 8   "typecheck": "tsc --project tsconfig.json --noEmit",
    9 9   "test": "echo 'Not implemented yet'",
    10 10   "storybook": "start-storybook -p 6006",
    11  - "build:storybook": "build-storybook -o dist/storybook",
    12 11   "build": "ts-node --swc webpack/build.ts --production",
     12 + "build:vercel": "ts-node --swc webpack/build-vercel-deploy-preview.ts && build-storybook -o dist/static/storybook",
    13 13   "dev:start": "./webpack/start_dev.sh",
    14 14   "start": "node dist/main.js",
    15 15   "dev:build": "ts-node --swc webpack/build.ts"
    skipped 23 lines
    39 39   "copy-webpack-plugin": "^11.0.0",
    40 40   "css-loader": "^6.2.0",
    41 41   "dotenv": "^10.0.0",
     42 + "html-replace-webpack-plugin": "^2.6.0",
    42 43   "html-webpack-plugin": "^5.3.2",
    43 44   "mini-css-extract-plugin": "^2.3.0",
    44 45   "node-sass": "^7.0.1",
    skipped 31 lines
  • ■ ■ ■ ■
    packages/web/vercel.json
    1 1  {
    2 2   "rewrites": [{
    3 3   "source": "/(.*)",
    4  - "destination": "/storybook/index.html"
     4 + "destination": "/index.html"
    5 5   }]
    6 6  }
    7 7   
  • ■ ■ ■ ■ ■ ■
    packages/web/webpack/build-vercel-deploy-preview.ts
     1 +import webpack from 'webpack';
     2 +import { getClientVars } from '../../shared/src/utils/env';
     3 +import { clientConfig } from './client';
     4 + 
     5 +// eslint-disable-next-line @typescript-eslint/no-var-requires
     6 +const HtmlReplaceWebpackPlugin = require('html-replace-webpack-plugin');
     7 + 
     8 +// Vercel webpack build for branch deploy previews without SSR
     9 +webpack(
     10 + [
     11 + clientConfig({
     12 + mode: 'production',
     13 + publicPath: '/',
     14 + plugins: [
     15 + new HtmlReplaceWebpackPlugin([
     16 + {
     17 + pattern: 'window.process = { env: {} };',
     18 + replacement: 'window.process = { env: ' + JSON.stringify(getClientVars()) + ' };',
     19 + },
     20 + ]),
     21 + ],
     22 + }),
     23 + ],
     24 + (err, stats) => {
     25 + // [Stats Object](#stats-object)
     26 + process.stdout.write(stats!.toString() + '\n');
     27 + }
     28 +);
     29 + 
  • ■ ■ ■ ■ ■
    packages/web/webpack/build.ts
    skipped 18 lines
    19 19   })
    20 20   .parse();
    21 21   
     22 +const publicPath = '/static/';
     23 + 
    22 24  webpack(
    23 25   [
    24  - clientConfig(args.production ? 'production' : 'development', args.watch),
    25  - serverConfig(args.production ? 'production' : 'development', args.watch),
     26 + clientConfig({
     27 + mode: args.production ? 'production' : 'development',
     28 + watch: args.watch,
     29 + publicPath,
     30 + }),
     31 + serverConfig({
     32 + mode: args.production ? 'production' : 'development',
     33 + watch: args.watch,
     34 + publicPath,
     35 + }),
    26 36   ],
    27 37   (err, stats) => {
    28 38   // [Stats Object](#stats-object)
    skipped 4 lines
  • ■ ■ ■ ■ ■ ■
    packages/web/webpack/client.ts
    skipped 3 lines
    4 4  import CopyPlugin from 'copy-webpack-plugin';
    5 5  import { configCommon, pluginsCommon, srcDir } from './common';
    6 6  import { Configuration } from 'webpack';
     7 +import { WebpackConfigOptions } from './config';
    7 8   
    8 9  const distDir = 'dist/static';
    9 10   
    10  -export const clientConfig: (mode: 'development' | 'production', watch: boolean) => Configuration = (
     11 +export const clientConfig: (options: WebpackConfigOptions) => Configuration = ({
    11 12   mode,
    12  - watch
    13  -) => ({
     13 + publicPath,
     14 + watch = false,
     15 + plugins = [],
     16 +}) => ({
    14 17   entry: join(__dirname, '..', srcDir, 'index.tsx'),
    15 18   ...configCommon(mode),
    16 19   module: {
    skipped 59 lines
    76 79   new CopyPlugin({
    77 80   patterns: [{ from: 'src/assets/sharing-image.png', to: 'sharing-image.png' }],
    78 81   }),
     82 + ...plugins,
    79 83   ],
    80 84   output: {
    81 85   filename: 'bundle.[fullhash].js',
    82 86   path: resolve(__dirname, '..', distDir),
    83  - publicPath: '/static/',
     87 + publicPath,
    84 88   assetModuleFilename: '[hash][ext]',
    85 89   },
    86 90   watch,
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    packages/web/webpack/config.ts
     1 +export type WebpackConfigOptions = {
     2 + mode: 'production' | 'development';
     3 + watch?: boolean;
     4 + publicPath: string;
     5 + plugins?: unknown[];
     6 +};
     7 + 
  • ■ ■ ■ ■ ■ ■
    packages/web/webpack/server.ts
    skipped 2 lines
    3 3  import CopyPlugin from 'copy-webpack-plugin';
    4 4  import { configCommon, pluginsCommon, srcDir } from './common';
    5 5  import { Configuration } from 'webpack';
     6 +import { WebpackConfigOptions } from './config';
    6 7   
    7 8  const distDir = 'dist';
    8 9   
    9  -export const serverConfig: (mode: 'development' | 'production', watch: boolean) => Configuration = (
     10 +export const serverConfig: (options: WebpackConfigOptions) => Configuration = ({
    10 11   mode,
    11  - watch
    12  -) => ({
     12 + watch = false,
     13 +}) => ({
    13 14   entry: join(__dirname, '..', srcDir, 'server.tsx'),
    14 15   ...configCommon(mode),
    15 16   module: {
    skipped 58 lines
  • ■ ■ ■ ■ ■
    yarn.lock
    skipped 8637 lines
    8638 8638   relateurl "^0.2.7"
    8639 8639   terser "^5.10.0"
    8640 8640   
     8641 +html-replace-webpack-plugin@^2.6.0:
     8642 + version "2.6.0"
     8643 + resolved "https://registry.yarnpkg.com/html-replace-webpack-plugin/-/html-replace-webpack-plugin-2.6.0.tgz#506d81e06cb5d6519281ce7c7dde7aeee04620e7"
     8644 + integrity sha512-BL0DgtqIAef2C8+Dq8v3Ork7FWLPVVkuFkd3DpFB8XxI8hgXiWytvWhGTztSwdiIrPstUPahL5g7W8ts/vuERw==
     8645 + 
    8641 8646  html-tags@^3.1.0:
    8642 8647   version "3.1.0"
    8643 8648   resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"
    skipped 6976 lines
Please wait...
Page is in error, reload to recover