Initial commit (as a partial copy of md:quality)
This commit is contained in:
		@@ -0,0 +1,169 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const path = require("path")
 | 
			
		||||
const deepExtend = require("deep-extend")
 | 
			
		||||
const webpack = require("webpack")
 | 
			
		||||
const TerserPlugin = require("terser-webpack-plugin")
 | 
			
		||||
const nodeExternals = require("webpack-node-externals")
 | 
			
		||||
 | 
			
		||||
const { getRepoInfo, getDevtool } = require("./_helpers")
 | 
			
		||||
const pkg = require("../package.json")
 | 
			
		||||
 | 
			
		||||
const projectBasePath = path.join(__dirname, "../")
 | 
			
		||||
 | 
			
		||||
const baseRules = [
 | 
			
		||||
  {
 | 
			
		||||
    test: /\.jsx?$/,
 | 
			
		||||
    include: [
 | 
			
		||||
      path.join(projectBasePath, "src"),
 | 
			
		||||
      path.join(projectBasePath, "node_modules", "object-assign-deep"),
 | 
			
		||||
    ],
 | 
			
		||||
    loader: "babel-loader",
 | 
			
		||||
    options: {
 | 
			
		||||
      retainLines: true,
 | 
			
		||||
      cacheDirectory: true,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    test: /\.(txt|yaml)$/,
 | 
			
		||||
    type: "asset/source",
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    test: /\.svg$/,
 | 
			
		||||
    use: ["@svgr/webpack"],
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    test: /\.(png|jpg|jpeg|gif)$/,
 | 
			
		||||
    type: "asset/inline",
 | 
			
		||||
  },
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
function buildConfig(
 | 
			
		||||
  {
 | 
			
		||||
    minimize = true,
 | 
			
		||||
    mangle = true,
 | 
			
		||||
    sourcemaps = true,
 | 
			
		||||
    includeDependencies = true,
 | 
			
		||||
  },
 | 
			
		||||
  customConfig
 | 
			
		||||
) {
 | 
			
		||||
  const gitInfo = getRepoInfo()
 | 
			
		||||
 | 
			
		||||
  var plugins = [
 | 
			
		||||
    new webpack.DefinePlugin({
 | 
			
		||||
      buildInfo: JSON.stringify({
 | 
			
		||||
        PACKAGE_VERSION: pkg.version,
 | 
			
		||||
        GIT_COMMIT: gitInfo.hash,
 | 
			
		||||
        GIT_DIRTY: gitInfo.dirty,
 | 
			
		||||
        BUILD_TIME: new Date().toUTCString(),
 | 
			
		||||
      }),
 | 
			
		||||
    }),
 | 
			
		||||
    new webpack.ProvidePlugin({
 | 
			
		||||
      process: "process/browser",
 | 
			
		||||
      Buffer: ["buffer", "Buffer"],
 | 
			
		||||
    }),
 | 
			
		||||
  ]
 | 
			
		||||
 | 
			
		||||
  const completeConfig = deepExtend(
 | 
			
		||||
    {},
 | 
			
		||||
    {
 | 
			
		||||
      mode: "production",
 | 
			
		||||
 | 
			
		||||
      entry: {},
 | 
			
		||||
 | 
			
		||||
      output: {
 | 
			
		||||
        path: path.join(projectBasePath, "dist"),
 | 
			
		||||
        publicPath: "/dist",
 | 
			
		||||
        filename: "[name].js",
 | 
			
		||||
        chunkFilename: "[name].js",
 | 
			
		||||
        globalObject: "this",
 | 
			
		||||
        library: {
 | 
			
		||||
          // when esm, library.name should be unset, so do not define here
 | 
			
		||||
          // when esm, library.export should be unset, so do not define here
 | 
			
		||||
          type: "umd",
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      target: "web",
 | 
			
		||||
 | 
			
		||||
      module: {
 | 
			
		||||
        rules: baseRules,
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      externals: includeDependencies
 | 
			
		||||
        ? {
 | 
			
		||||
            esprima: "esprima",
 | 
			
		||||
          }
 | 
			
		||||
        : [
 | 
			
		||||
            nodeExternals({
 | 
			
		||||
              importType: (moduleName) => {
 | 
			
		||||
                return `commonjs ${moduleName}`
 | 
			
		||||
              },
 | 
			
		||||
            }),
 | 
			
		||||
          ],
 | 
			
		||||
      resolve: {
 | 
			
		||||
        modules: [path.join(projectBasePath, "./src"), "node_modules"],
 | 
			
		||||
        extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
 | 
			
		||||
        alias: {
 | 
			
		||||
          // these aliases make sure that we don't bundle same libraries twice
 | 
			
		||||
          // when the versions of these libraries diverge between swagger-js and swagger-ui
 | 
			
		||||
          "@babel/runtime-corejs3": path.resolve(
 | 
			
		||||
            __dirname,
 | 
			
		||||
            "..",
 | 
			
		||||
            "node_modules/@babel/runtime-corejs3"
 | 
			
		||||
          ),
 | 
			
		||||
          "js-yaml": path.resolve(__dirname, "..", "node_modules/js-yaml"),
 | 
			
		||||
          lodash: path.resolve(__dirname, "..", "node_modules/lodash"),
 | 
			
		||||
          "react-is": path.resolve(__dirname, "..", "node_modules/react-is"),
 | 
			
		||||
          "safe-buffer": path.resolve(
 | 
			
		||||
            __dirname,
 | 
			
		||||
            "..",
 | 
			
		||||
            "node_modules/safe-buffer"
 | 
			
		||||
          ),
 | 
			
		||||
        },
 | 
			
		||||
        fallback: {
 | 
			
		||||
          fs: false,
 | 
			
		||||
          stream: require.resolve("stream-browserify"),
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      devtool: getDevtool(sourcemaps, minimize),
 | 
			
		||||
 | 
			
		||||
      performance: {
 | 
			
		||||
        hints: "error",
 | 
			
		||||
        maxEntrypointSize: 13312000,
 | 
			
		||||
        maxAssetSize: 133312000,
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      optimization: {
 | 
			
		||||
        minimize: !!minimize,
 | 
			
		||||
        minimizer: [
 | 
			
		||||
          (compiler) =>
 | 
			
		||||
            new TerserPlugin({
 | 
			
		||||
              terserOptions: {
 | 
			
		||||
                sourceMap: sourcemaps,
 | 
			
		||||
                mangle: !!mangle,
 | 
			
		||||
                keep_classnames:
 | 
			
		||||
                  !customConfig.mode || customConfig.mode === "production",
 | 
			
		||||
                keep_fnames:
 | 
			
		||||
                  !customConfig.mode || customConfig.mode === "production",
 | 
			
		||||
                output: {
 | 
			
		||||
                  comments: false,
 | 
			
		||||
                },
 | 
			
		||||
              },
 | 
			
		||||
            }).apply(compiler),
 | 
			
		||||
        ],
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    customConfig
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  // deepExtend mangles Plugin instances, this doesn't
 | 
			
		||||
  completeConfig.plugins = plugins.concat(customConfig.plugins || [])
 | 
			
		||||
 | 
			
		||||
  return completeConfig
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = buildConfig
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const { gitDescribeSync } = require("git-describe")
 | 
			
		||||
 | 
			
		||||
function getRepoInfo() {
 | 
			
		||||
  try {
 | 
			
		||||
    return gitDescribeSync(__dirname)
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    console.error(e)
 | 
			
		||||
    return {
 | 
			
		||||
      hash: "noGit",
 | 
			
		||||
      dirty: false,
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getDevtool(sourcemaps, minimize) {
 | 
			
		||||
  if (!sourcemaps) return false
 | 
			
		||||
  return minimize ? "source-map" : "cheap-module-source-map"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  getRepoInfo,
 | 
			
		||||
  getDevtool,
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Dev Note:
 | 
			
		||||
 * StatsWriterPlugin is disabled by default; uncomment to enable
 | 
			
		||||
 * when enabled, rebuilding the bundle will cause error for assetSizeLimit,
 | 
			
		||||
 * which we want to keep out of CI/CD
 | 
			
		||||
 * post build, cli command: npx webpack-bundle-analyzer <path>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const { DuplicatesPlugin } = require("inspectpack/plugin")
 | 
			
		||||
const {
 | 
			
		||||
  WebpackBundleSizeAnalyzerPlugin,
 | 
			
		||||
} = require("webpack-bundle-size-analyzer")
 | 
			
		||||
const configBuilder = require("./_config-builder")
 | 
			
		||||
 | 
			
		||||
// import path from "path"
 | 
			
		||||
// import { StatsWriterPlugin } from "webpack-stats-plugin"
 | 
			
		||||
 | 
			
		||||
const result = configBuilder(
 | 
			
		||||
  {
 | 
			
		||||
    minimize: true,
 | 
			
		||||
    mangle: true,
 | 
			
		||||
    sourcemaps: false,
 | 
			
		||||
    includeDependencies: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    entry: {
 | 
			
		||||
      "swagger-ui-bundle": ["./src/index.js"],
 | 
			
		||||
    },
 | 
			
		||||
    output: {
 | 
			
		||||
      globalObject: "this",
 | 
			
		||||
      library: {
 | 
			
		||||
        name: "SwaggerUIBundle",
 | 
			
		||||
        export: "default",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    plugins: [
 | 
			
		||||
      new DuplicatesPlugin({
 | 
			
		||||
        // emit compilation warning or error? (Default: `false`)
 | 
			
		||||
        emitErrors: false,
 | 
			
		||||
        // display full duplicates information? (Default: `false`)
 | 
			
		||||
        verbose: false,
 | 
			
		||||
      }),
 | 
			
		||||
      new WebpackBundleSizeAnalyzerPlugin("log.bundle-sizes.swagger-ui.txt"),
 | 
			
		||||
      // new StatsWriterPlugin({
 | 
			
		||||
      //   filename: path.join("log.bundle-stats.swagger-ui.json"),
 | 
			
		||||
      //   fields: null,
 | 
			
		||||
      // }),
 | 
			
		||||
    ],
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
module.exports = result
 | 
			
		||||
							
								
								
									
										29
									
								
								public/static/js/swagger/swagger-ui-5.17.14/webpack/core.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								public/static/js/swagger/swagger-ui-5.17.14/webpack/core.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const configBuilder = require("./_config-builder")
 | 
			
		||||
 | 
			
		||||
const result = configBuilder(
 | 
			
		||||
  {
 | 
			
		||||
    minimize: true,
 | 
			
		||||
    mangle: true,
 | 
			
		||||
    sourcemaps: true,
 | 
			
		||||
    includeDependencies: false,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    entry: {
 | 
			
		||||
      "swagger-ui": ["./src/index.js"],
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    output: {
 | 
			
		||||
      globalObject: "this",
 | 
			
		||||
      library: {
 | 
			
		||||
        name: "SwaggerUICore",
 | 
			
		||||
        export: "default",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
module.exports = result
 | 
			
		||||
@@ -0,0 +1,74 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const path = require("path")
 | 
			
		||||
 | 
			
		||||
const configBuilder = require("./_config-builder")
 | 
			
		||||
const styleConfig = require("./stylesheets")
 | 
			
		||||
 | 
			
		||||
// Pretty much the same as devConfig, but with changes to port and static.directory
 | 
			
		||||
const devE2eConfig = configBuilder(
 | 
			
		||||
  {
 | 
			
		||||
    minimize: false,
 | 
			
		||||
    mangle: false,
 | 
			
		||||
    sourcemaps: true,
 | 
			
		||||
    includeDependencies: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    mode: "development",
 | 
			
		||||
    entry: {
 | 
			
		||||
      "swagger-ui-bundle": ["./src/core/index.js"],
 | 
			
		||||
      "swagger-ui-standalone-preset": [
 | 
			
		||||
        "./src/standalone/presets/standalone/index.js",
 | 
			
		||||
      ],
 | 
			
		||||
      "swagger-ui": "./src/style/main.scss",
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    performance: {
 | 
			
		||||
      hints: false,
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    output: {
 | 
			
		||||
      filename: "[name].js",
 | 
			
		||||
      chunkFilename: "[id].js",
 | 
			
		||||
      library: {
 | 
			
		||||
        name: "[name]",
 | 
			
		||||
        export: "default",
 | 
			
		||||
      },
 | 
			
		||||
      publicPath: "/",
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    devServer: {
 | 
			
		||||
      allowedHosts: "all", // for development within VMs
 | 
			
		||||
      headers: {
 | 
			
		||||
        "Access-Control-Allow-Origin": "*",
 | 
			
		||||
        "Access-Control-Allow-Methods": "*",
 | 
			
		||||
        "Access-Control-Allow-Headers": "*",
 | 
			
		||||
      },
 | 
			
		||||
      port: 3230,
 | 
			
		||||
      host: "0.0.0.0",
 | 
			
		||||
      hot: true,
 | 
			
		||||
      static: {
 | 
			
		||||
        directory: path.join(__dirname, "../", "test", "e2e-cypress", "static"),
 | 
			
		||||
        publicPath: "/",
 | 
			
		||||
      },
 | 
			
		||||
      client: {
 | 
			
		||||
        logging: "info",
 | 
			
		||||
        progress: true,
 | 
			
		||||
      },
 | 
			
		||||
      devMiddleware: {},
 | 
			
		||||
    },
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// mix in the style config's plugins and loader rules
 | 
			
		||||
 | 
			
		||||
devE2eConfig.plugins = [...devE2eConfig.plugins, ...styleConfig.plugins]
 | 
			
		||||
 | 
			
		||||
devE2eConfig.module.rules = [
 | 
			
		||||
  ...devE2eConfig.module.rules,
 | 
			
		||||
  ...styleConfig.module.rules,
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
module.exports = devE2eConfig
 | 
			
		||||
							
								
								
									
										127
									
								
								public/static/js/swagger/swagger-ui-5.17.14/webpack/dev.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								public/static/js/swagger/swagger-ui-5.17.14/webpack/dev.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,127 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const path = require("path")
 | 
			
		||||
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin")
 | 
			
		||||
const HtmlWebpackPlugin = require("html-webpack-plugin")
 | 
			
		||||
const {
 | 
			
		||||
  HtmlWebpackSkipAssetsPlugin,
 | 
			
		||||
} = require("html-webpack-skip-assets-plugin")
 | 
			
		||||
 | 
			
		||||
const configBuilder = require("./_config-builder")
 | 
			
		||||
const styleConfig = require("./stylesheets")
 | 
			
		||||
 | 
			
		||||
const projectBasePath = path.join(__dirname, "../")
 | 
			
		||||
const isDevelopment = process.env.NODE_ENV !== "production"
 | 
			
		||||
 | 
			
		||||
const devConfig = configBuilder(
 | 
			
		||||
  {
 | 
			
		||||
    minimize: false,
 | 
			
		||||
    mangle: false,
 | 
			
		||||
    sourcemaps: true,
 | 
			
		||||
    includeDependencies: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    mode: "development",
 | 
			
		||||
    entry: {
 | 
			
		||||
      "swagger-ui-bundle": ["./src/core/index.js"],
 | 
			
		||||
      "swagger-ui-standalone-preset": [
 | 
			
		||||
        "./src/standalone/presets/standalone/index.js",
 | 
			
		||||
      ],
 | 
			
		||||
      "swagger-ui": "./src/style/main.scss",
 | 
			
		||||
      vendors: ["react-refresh/runtime"],
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    performance: {
 | 
			
		||||
      hints: false,
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    output: {
 | 
			
		||||
      filename: "[name].js",
 | 
			
		||||
      chunkFilename: "[id].js",
 | 
			
		||||
      library: {
 | 
			
		||||
        name: "[name]",
 | 
			
		||||
        export: "default",
 | 
			
		||||
      },
 | 
			
		||||
      publicPath: "/",
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    devServer: {
 | 
			
		||||
      allowedHosts: "all", // for development within VMs
 | 
			
		||||
      headers: {
 | 
			
		||||
        "Access-Control-Allow-Origin": "*",
 | 
			
		||||
        "Access-Control-Allow-Methods": "*",
 | 
			
		||||
        "Access-Control-Allow-Headers": "*",
 | 
			
		||||
      },
 | 
			
		||||
      port: 3200,
 | 
			
		||||
      host: "0.0.0.0",
 | 
			
		||||
      hot: true,
 | 
			
		||||
      static: {
 | 
			
		||||
        directory: path.resolve(projectBasePath, "dev-helpers"),
 | 
			
		||||
        publicPath: "/",
 | 
			
		||||
      },
 | 
			
		||||
      client: {
 | 
			
		||||
        logging: "info",
 | 
			
		||||
        progress: true,
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    module: {
 | 
			
		||||
      rules: [
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.jsx?$/,
 | 
			
		||||
          include: [
 | 
			
		||||
            path.join(projectBasePath, "src"),
 | 
			
		||||
            path.join(projectBasePath, "node_modules", "object-assign-deep"),
 | 
			
		||||
          ],
 | 
			
		||||
          loader: "babel-loader",
 | 
			
		||||
          options: {
 | 
			
		||||
            retainLines: true,
 | 
			
		||||
            cacheDirectory: true,
 | 
			
		||||
            plugins: [
 | 
			
		||||
              isDevelopment && require.resolve("react-refresh/babel"),
 | 
			
		||||
            ].filter(Boolean),
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.(txt|yaml)$/,
 | 
			
		||||
          type: "asset/source",
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.svg$/,
 | 
			
		||||
          use: ["@svgr/webpack"],
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
          test: /\.(png|jpg|jpeg|gif)$/,
 | 
			
		||||
          type: "asset/inline",
 | 
			
		||||
        },
 | 
			
		||||
      ],
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    plugins: [
 | 
			
		||||
      isDevelopment && new ReactRefreshWebpackPlugin({ library: "[name]" }),
 | 
			
		||||
      new HtmlWebpackPlugin({
 | 
			
		||||
        template: path.join(projectBasePath, "dev-helpers", "index.html"),
 | 
			
		||||
      }),
 | 
			
		||||
      new HtmlWebpackSkipAssetsPlugin({
 | 
			
		||||
        skipAssets: [/swagger-ui\.js/],
 | 
			
		||||
      }),
 | 
			
		||||
    ].filter(Boolean),
 | 
			
		||||
 | 
			
		||||
    optimization: {
 | 
			
		||||
      runtimeChunk: "single", // for multiple entry points using ReactRefreshWebpackPlugin
 | 
			
		||||
    },
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// mix in the style config's plugins and loader rules
 | 
			
		||||
 | 
			
		||||
devConfig.plugins = [...devConfig.plugins, ...styleConfig.plugins]
 | 
			
		||||
 | 
			
		||||
devConfig.module.rules = [
 | 
			
		||||
  ...devConfig.module.rules,
 | 
			
		||||
  ...styleConfig.module.rules,
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
module.exports = devConfig
 | 
			
		||||
@@ -0,0 +1,90 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Dev Note:
 | 
			
		||||
 * StatsWriterPlugin is disabled by default; uncomment to enable
 | 
			
		||||
 * when enabled, rebuilding the bundle will cause error for assetSizeLimit,
 | 
			
		||||
 * which we want to keep out of CI/CD
 | 
			
		||||
 * post build, cli command: npx webpack-bundle-analyzer <path>
 | 
			
		||||
 */
 | 
			
		||||
const configBuilder = require("./_config-builder")
 | 
			
		||||
const { DuplicatesPlugin } = require("inspectpack/plugin")
 | 
			
		||||
const {
 | 
			
		||||
  WebpackBundleSizeAnalyzerPlugin,
 | 
			
		||||
} = require("webpack-bundle-size-analyzer")
 | 
			
		||||
const nodeExternals = require("webpack-node-externals")
 | 
			
		||||
const { getDevtool } = require("./_helpers")
 | 
			
		||||
// const { StatsWriterPlugin } = require("webpack-stats-plugin")
 | 
			
		||||
 | 
			
		||||
const minimize = true
 | 
			
		||||
const sourcemaps = true
 | 
			
		||||
 | 
			
		||||
const result = configBuilder(
 | 
			
		||||
  {
 | 
			
		||||
    minimize,
 | 
			
		||||
    mangle: true,
 | 
			
		||||
    sourcemaps,
 | 
			
		||||
    includeDependencies: false,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    target: "browserslist",
 | 
			
		||||
    entry: {
 | 
			
		||||
      "swagger-ui-es-bundle-core": ["./src/index.js"],
 | 
			
		||||
    },
 | 
			
		||||
    experiments: {
 | 
			
		||||
      outputModule: true,
 | 
			
		||||
    },
 | 
			
		||||
    output: {
 | 
			
		||||
      module: true,
 | 
			
		||||
      libraryTarget: "module",
 | 
			
		||||
      library: {
 | 
			
		||||
        type: "module",
 | 
			
		||||
      },
 | 
			
		||||
      environment: {
 | 
			
		||||
        module: true,
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    devtool: getDevtool(sourcemaps, minimize),
 | 
			
		||||
    externalsType: "module",
 | 
			
		||||
    externals: [
 | 
			
		||||
      {
 | 
			
		||||
        esprima: "esprima",
 | 
			
		||||
      },
 | 
			
		||||
      nodeExternals({
 | 
			
		||||
        allowlist: [
 | 
			
		||||
          "deep-extend", // uses Buffer as global symbol
 | 
			
		||||
          "randombytes", // uses require('safe-buffer')
 | 
			
		||||
          "sha.js", // uses require('safe-buffer')
 | 
			
		||||
          "xml", // uses require('stream')
 | 
			
		||||
          "process/browser", // is injected via ProvidePlugin
 | 
			
		||||
          /^readable-stream/, // byproduct of buffer ProvidePlugin injection
 | 
			
		||||
          "util-deprecate", // dependency of readable-stream
 | 
			
		||||
          "inherits", // dependency of readable-stream
 | 
			
		||||
          "events", // dependency of readable-stream
 | 
			
		||||
          "safe-buffer", // contained in resolve.alias
 | 
			
		||||
          "string_decoder/", // byproduct of buffer ProvidePlugin injection
 | 
			
		||||
          "buffer", // buffer is injected via ProvidePlugin
 | 
			
		||||
        ],
 | 
			
		||||
        importType: (moduleName) => {
 | 
			
		||||
          return `module ${moduleName}`
 | 
			
		||||
        },
 | 
			
		||||
      }),
 | 
			
		||||
    ],
 | 
			
		||||
    plugins: [
 | 
			
		||||
      new DuplicatesPlugin({
 | 
			
		||||
        emitErrors: false,
 | 
			
		||||
        verbose: false,
 | 
			
		||||
      }),
 | 
			
		||||
      new WebpackBundleSizeAnalyzerPlugin(
 | 
			
		||||
        "log.es-bundle-core-sizes.swagger-ui.txt"
 | 
			
		||||
      ),
 | 
			
		||||
      // new StatsWriterPlugin({
 | 
			
		||||
      //   filename: path.join("log.es-bundle-core-stats.swagger-ui.json"),
 | 
			
		||||
      //   fields: null,
 | 
			
		||||
      // }),
 | 
			
		||||
    ],
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
module.exports = result
 | 
			
		||||
@@ -0,0 +1,54 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/** Dev Note:
 | 
			
		||||
 * StatsWriterPlugin is disabled by default; uncomment to enable
 | 
			
		||||
 * when enabled, rebuilding the bundle will cause error for assetSizeLimit,
 | 
			
		||||
 * which we want to keep out of CI/CD
 | 
			
		||||
 * post build, cli command: npx webpack-bundle-analyzer <path>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const configBuilder = require("./_config-builder")
 | 
			
		||||
const { DuplicatesPlugin } = require("inspectpack/plugin")
 | 
			
		||||
const {
 | 
			
		||||
  WebpackBundleSizeAnalyzerPlugin,
 | 
			
		||||
} = require("webpack-bundle-size-analyzer")
 | 
			
		||||
// import path from "path"
 | 
			
		||||
// import { StatsWriterPlugin } from "webpack-stats-plugin"
 | 
			
		||||
 | 
			
		||||
const result = configBuilder(
 | 
			
		||||
  {
 | 
			
		||||
    minimize: true,
 | 
			
		||||
    mangle: true,
 | 
			
		||||
    sourcemaps: false,
 | 
			
		||||
    includeDependencies: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    entry: {
 | 
			
		||||
      "swagger-ui-es-bundle": ["./src/index.js"],
 | 
			
		||||
    },
 | 
			
		||||
    output: {
 | 
			
		||||
      globalObject: "this",
 | 
			
		||||
      library: {
 | 
			
		||||
        type: "commonjs2",
 | 
			
		||||
        export: "default",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
    plugins: [
 | 
			
		||||
      new DuplicatesPlugin({
 | 
			
		||||
        // emit compilation warning or error? (Default: `false`)
 | 
			
		||||
        emitErrors: false,
 | 
			
		||||
        // display full duplicates information? (Default: `false`)
 | 
			
		||||
        verbose: false,
 | 
			
		||||
      }),
 | 
			
		||||
      new WebpackBundleSizeAnalyzerPlugin("log.es-bundle-sizes.swagger-ui.txt"),
 | 
			
		||||
      // new StatsWriterPlugin({
 | 
			
		||||
      //   filename: path.join("log.es-bundle-stats.swagger-ui.json"),
 | 
			
		||||
      //   fields: null,
 | 
			
		||||
      // }),
 | 
			
		||||
    ],
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
module.exports = result
 | 
			
		||||
@@ -0,0 +1,30 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const configBuilder = require("./_config-builder")
 | 
			
		||||
 | 
			
		||||
const result = configBuilder(
 | 
			
		||||
  {
 | 
			
		||||
    minimize: true,
 | 
			
		||||
    mangle: true,
 | 
			
		||||
    sourcemaps: false,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    entry: {
 | 
			
		||||
      "swagger-ui-standalone-preset": [
 | 
			
		||||
        "./src/standalone/presets/standalone/index.js",
 | 
			
		||||
      ],
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    output: {
 | 
			
		||||
      globalObject: "this",
 | 
			
		||||
      library: {
 | 
			
		||||
        name: "SwaggerUIStandalonePreset",
 | 
			
		||||
        export: "default",
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
module.exports = result
 | 
			
		||||
@@ -0,0 +1,83 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @prettier
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// NOTE: this config *does not* inherit from `_config-builder`.
 | 
			
		||||
// It is also used in the dev config.
 | 
			
		||||
 | 
			
		||||
const path = require("path")
 | 
			
		||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  mode: "production",
 | 
			
		||||
 | 
			
		||||
  entry: {
 | 
			
		||||
    "swagger-ui": "./src/style/main.scss",
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  module: {
 | 
			
		||||
    rules: [
 | 
			
		||||
      {
 | 
			
		||||
        test: [/\.(scss)(\?.*)?$/],
 | 
			
		||||
        use: [
 | 
			
		||||
          {
 | 
			
		||||
            loader: MiniCssExtractPlugin.loader,
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            loader: "css-loader",
 | 
			
		||||
            options: { sourceMap: true },
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            loader: "postcss-loader",
 | 
			
		||||
            options: {
 | 
			
		||||
              postcssOptions: {
 | 
			
		||||
                sourceMap: true,
 | 
			
		||||
                plugins: [
 | 
			
		||||
                  require("cssnano")(),
 | 
			
		||||
                  "postcss-preset-env", // applies autoprefixer
 | 
			
		||||
                ],
 | 
			
		||||
              },
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            loader: "sass-loader",
 | 
			
		||||
            options: {
 | 
			
		||||
              // Prefer `dart-sass`
 | 
			
		||||
              implementation: require("sass"),
 | 
			
		||||
              sourceMap: true,
 | 
			
		||||
              sassOptions: {
 | 
			
		||||
                quietDeps: true,
 | 
			
		||||
              },
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        ],
 | 
			
		||||
      },
 | 
			
		||||
    ],
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  plugins: [
 | 
			
		||||
    new MiniCssExtractPlugin({
 | 
			
		||||
      filename: "[name].css",
 | 
			
		||||
    }),
 | 
			
		||||
  ],
 | 
			
		||||
 | 
			
		||||
  devtool: "source-map",
 | 
			
		||||
 | 
			
		||||
  output: {
 | 
			
		||||
    path: path.join(__dirname, "../", "dist"),
 | 
			
		||||
    publicPath: "/dist",
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  optimization: {
 | 
			
		||||
    splitChunks: {
 | 
			
		||||
      cacheGroups: {
 | 
			
		||||
        styles: {
 | 
			
		||||
          name: "styles",
 | 
			
		||||
          test: /\.css$/,
 | 
			
		||||
          chunks: "all",
 | 
			
		||||
          enforce: true,
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user