UNPKG

@expo/webpack-config

Version:

The default Webpack configuration used to build Expo apps targeting the web.

47 lines 2.04 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin")); const env_1 = require("../env"); const utils_1 = require("../utils"); const DEFAULT_MINIFY = { removeComments: true, collapseWhitespace: true, removeRedundantAttributes: true, useShortDoctype: true, removeEmptyAttributes: true, removeStyleLinkTypeAttributes: true, keepClosingSlash: true, minifyJS: true, minifyCSS: true, minifyURLs: true, }; class ExpoHtmlWebpackPlugin extends html_webpack_plugin_1.default { constructor(env) { var _a, _b, _c; const locations = env.locations || env_1.getPaths(env.projectRoot); const config = env_1.getConfig(env); const isProduction = env_1.getMode(env) === 'production'; /** * The user can disable minify with * `web.minifyHTML = false || {}` */ const minify = utils_1.overrideWithPropertyOrConfig(isProduction ? (_b = (_a = config.web) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.minifyHTML : false, DEFAULT_MINIFY); // Generates an `index.html` file with the <script> injected. super({ // The file to write the HTML to. filename: locations.production.indexHtml, // The title to use for the generated HTML document. title: (_c = config.web) === null || _c === void 0 ? void 0 : _c.name, // Pass a html-minifier options object to minify the output. // https://github.com/kangax/html-minifier#options-quick-reference minify, // The `webpack` require path to the template. template: locations.template.indexHtml, }); } } exports.default = ExpoHtmlWebpackPlugin; //# sourceMappingURL=ExpoHtmlWebpackPlugin.js.map