SwaggerUI is now built using `webpack@5`, with dev support for `webpack-dev-server@4` - ES Module output bundle path now points to `swagger-ui-es-bundle-core`, which does not include dependencies - No change to CommonJS output bundle or path - Now uses Asset Modules, which replaces `file-loader`, `raw-loader`, and `url-loader` - Removed unused rules/loaders for `.woff | .woff2 | .ttf | .eot` fonts and html - Node polyfills are no longer bundled with `webpack@5`, and must be loaded separately and/or use `resolve.fallback`. As an example, SwaggerUI loads `process`, `buffer`, and `stream-browserify` as `devDependencies` in order to build development and production bundles. SwaggerUI-React - Now imports `swagger-ui-es-bundle-core`, and similarly outputs `swagger-ui-es-bundle-core` to its `dist` directory Dev notes: - Order of execution matters for the production npm build scripts. `build-stylesheets` needs to get built first, then cleanup of any empty artifacts, before building the various production bundles - `Dev-helpers` now relies on `HTMLWebpackPlugin` to inject css and bundle files
84 lines
1.6 KiB
JavaScript
84 lines
1.6 KiB
JavaScript
/**
|
|
* @prettier
|
|
*/
|
|
|
|
// NOTE: this config *does not* inherit from `_config-builder`.
|
|
// It is also used in the dev config.
|
|
|
|
import path from "path"
|
|
import MiniCssExtractPlugin from "mini-css-extract-plugin"
|
|
|
|
export default {
|
|
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: {
|
|
sourceMap: true,
|
|
sassOptions: {
|
|
outputStyle: "expanded",
|
|
// sourceMapContents: "true", // if sourceMap: true, sassOptions.sourceMapContents is ignored
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
|
|
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,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|