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/less-themes-webpack-plugin@2.2.0/src/Plugin.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/less-themes-webpack-plugin@2.2.0/src/Plugin.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const { dirname, resolve, relative } = require('path');\nconst { writeFileSync } = require('fs');\nconst MiniCssExtractPlugin = require('mini-css-extract-plugin');\nconst processOptionsThemes = require('./processOptionsThemes');\nconst HtmlWebpackPlugin = require('safe-require')('html-webpack-plugin');\nconst temp = require('temp');\nconst mkdirp = require('mkdirp');\nconst { buildTempFiles } = require('./utils.js');\nconst { validate } = require('schema-utils');\n\ntemp.track();\n\nconst tempDir = temp.mkdirSync();\nconst THEME_NAME = 'less-themes-webpack-plugin';\nconst defaultOptions = {\n\tfilename: '[name].min.css',\n\tthemesPath: '',\n\tthemes: { main: '' },\n\tsourceMap: false,\n\tskipLoaders: false\n};\nconst optionsSchema = {\n\ttype: 'object',\n\tproperties: {\n\t\tfilename: { type: 'string' },\n\t\tthemesPath: { type: 'string' },\n\t\tthemes: { type: 'object' },\n\t\tsourceMap: { type: 'boolean' },\n\t\tskipLoaders: { type: 'boolean' }\n\t},\n\tadditionalProperties: false\n};\n\nconst escapeStringRegexp = (string) => {\n\treturn string\n\t\t.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n\t\t.replace(/-/g, '\\\\x2d');\n};\n\n/**\n * Can handle any amount of nesting. The file extension is not necessary in the file name if the actual file has an extension of `.less`. File definitions can be a string or an array of strings.\n *\n * @typedef {object|string|string[]} themeDef\n *\n * @property {string} [path] - Appends a directory to the current path. Can be specified at any level.\n * @property {string|string[]} [include] - Appends another directory to the current path. Can be specified at any level.\n * @property {boolean} [isReference=true] - Imports files in this chunk as a reference. Applies to all children objects unless overridden by the child.\n * @property {themeDef} [*] - Nested theme def. The key name is added to the theme name, dot delimited.\n */\n\n/**\n * @name Installation\n * @summary\n *\n * ```\n * npm install less-themes-webpack-plugin --save-dev\n * ```\n */\n\n/**\n * @name Compatibility\n * @summary\n * Requires:\n * - webpack 5+\n * - node 10+\n *\n * For webpack 4 use less-themes-webpack-plugin@1.5.1\n *\n * Since this library uses [postcss-loader](https://github.com/postcss/postcss-loader) you must have a postcss config in the root of your project for this plugin to work.\n *\n * This library has a peer dependency of [Less](https://github.com/less/less.js).\n *\n * This plugin automatically adds its own loader and:\n * - [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin)\n * - [less-loader](https://github.com/webpack-contrib/less-loader)\n * - [css-loader](https://github.com/webpack-contrib/css-loader)\n * - [postcss-loader](https://github.com/postcss/postcss-loader)\n *\n * You shouldn't need to install them or reference them in any way in your webpack config.\n *\n * If you are using [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin), then this plugin will add a reference to the first compiled css theme file in the generated html (in the following example that would be main.light.mobile.min.css).\n */\n\n/**\n * @param {object} [options]\n *\n * @param {string} [options.filename=[name].min.css] - The output file name. Replaces [name] with a generated name based on the themes option. In the following example you would get four .css files: <br>• main.light.mobile.min.css <br>• main.light.desktop.min.css <br>• main.dark.mobile.min.css <br>• main.dark.desktop.min.css\n *\n * @param {string} [options.themesPath=''] - The base path to the theme files in `options.themes`.\n *\n * @param {boolean} [options.sourceMap=false] - This is passed directly into MiniCssExtractPlugin and loaders.\n *\n * @param {boolean} [options.skipLoaders=false] - If true then MiniCssExtractPlugin and loaders won't be added. You must provide them in your webpack config.\n *\n * @param {themeDef} [options.themes] - Defines which files to import for each different theme. If no themes are defined then a single css file will be produced named 'main.min.css'\n *\n * @name Usage\n * @summary\n * In your js files import less like this:\n * ```javascript\n * import './stylesForThisFile.less';\n * ```\n *\n * @example\n * ```javascript\n * // webpack.config.js\n * const ThemesPlugin = require('less-themes-webpack-plugin');\n *\n * module.exports = {\n *    // ...\n *    plugins: [\n *\t\tnew ThemesPlugin({\n *\t\t\tfilename: '[name].min.css',\n *\t\t\tthemesPath: './themes',\n *\t\t\tsourceMap: true,\n *\t\t\tthemes: {\n *\t\t\t\tmain: {\n *\t\t\t\t\tlight: {\n *\t\t\t\t\t\tmobile: [\n *\t\t\t\t\t\t\t'main/light.less'\n *\t\t\t\t\t\t],\n *\t\t\t\t\t\tdesktop: [\n *\t\t\t\t\t\t\t'main/light.less',\n *\t\t\t\t\t\t\t'main/desktop.less'\n *\t\t\t\t\t\t]\n *\t\t\t\t\t},\n *\t\t\t\t\tdark: {\n *\t\t\t\t\t\tmobile: [\n *\t\t\t\t\t\t\t'main/light.less',\n *\t\t\t\t\t\t\t'main/dark.less'\n *\t\t\t\t\t\t],\n *\t\t\t\t\t\tdesktop: [\n *\t\t\t\t\t\t\t'main/light.less',\n *\t\t\t\t\t\t\t'main/dark.less',\n *\t\t\t\t\t\t\t'main/desktop.less'\n *\t\t\t\t\t\t]\n *\t\t\t\t\t}\n *\t\t\t\t}\n *\t\t\t}\n *\t\t})\n *    ]\n * };\n *\n * // The following will produce the same output:\n * module.exports = {\n *    // ...\n *    plugins: [\n *\t\tnew ThemesPlugin({\n *\t\t\tfilename: '[name].min.css',\n *\t\t\tthemesPath: './themes',\n *\t\t\tsourceMap: true,\n *\t\t\tthemes: {\n *\t\t\t\tmain: {\n *\t\t\t\t\tpath: 'main',\n *\t\t\t\t\tinclude: 'light',\n *\t\t\t\t\tlight: {\n *\t\t\t\t\t\tmobile: [],\n *\t\t\t\t\t\tdesktop: 'desktop'\n *\t\t\t\t\t},\n *\t\t\t\t\tdark: {\n *\t\t\t\t\t\tinclude: 'dark',\n *\t\t\t\t\t\tmobile: [],\n *\t\t\t\t\t\tdesktop: 'desktop'\n *\t\t\t\t\t}\n *\t\t\t\t}\n *\t\t\t}\n *\t\t})\n *    ]\n * };\n * ```\n */\n\nclass ThemesPlugin {\n\tconstructor(options) {\n\t\tthis.options = { ...defaultOptions, ...options };\n\n\t\tvalidate(optionsSchema, this.options, {\n\t\t\tbaseDataPath: 'options',\n\t\t\tname: THEME_NAME\n\t\t});\n\n\t\tconst [themes, themeNames] = processOptionsThemes(\n\t\t\tthis.options.themes,\n\t\t\tthis.options.themesPath\n\t\t);\n\n\t\tthis._themes = themes;\n\t\tthis._themeNames = themeNames;\n\t}\n\n\t_buildThemeFiles(compiler) {\n\t\tbuildTempFiles(tempDir, this._themes)\n\t\t\t.forEach((file) => {\n\t\t\t\tmkdirp.sync(file.dir);\n\t\t\t\twriteFileSync(file.location, file.content);\n\t\t\t});\n\t}\n\n\t_hasHtmlWebpackPlugin(compiler) {\n\t\treturn HtmlWebpackPlugin !== undefined &&\n\t\t\tcompiler.options.plugins\n\t\t\t\t.some((plugin) => plugin instanceof HtmlWebpackPlugin);\n\t}\n\n\t_addMiniCssExtractPlugin(compiler, filename) {\n\t\tconst miniCssExtractPlugin = new MiniCssExtractPlugin({ filename });\n\n\t\tcompiler.options.plugins.push(miniCssExtractPlugin);\n\t\tminiCssExtractPlugin.apply(compiler);\n\t}\n\n\t_addChunks(compiler) {\n\t\tthis._themeNames.forEach((themeName) => {\n\t\t\tcompiler.options.optimization.splitChunks.cacheGroups[themeName] = {\n\t\t\t\ttest: new RegExp('\\.' + escapeStringRegexp(themeName) + '\\.less$'),\n\t\t\t\tname: themeName,\n\t\t\t\tchunks: 'all',\n\t\t\t\tenforce: true,\n\t\t\t\treuseExistingChunk: true\n\t\t\t};\n\t\t});\n\t}\n\n\t_cleanAssetTagsStyles(tag, data) {\n\t\tif (tag.attributes.href.includes(this._themeNames[0])) {\n\t\t\tdata.assetTags.styles = [tag];\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t_alterAssetTags(data, callback) {\n\t\tdata.assetTags.styles\n\t\t\t.some((tag) => this._cleanAssetTagsStyles(tag, data));\n\n\t\tcallback(null, data);\n\t}\n\n\t_onCompile(compilation) {\n\t\tHtmlWebpackPlugin\n\t\t\t.getHooks(compilation)\n\t\t\t.alterAssetTags\n\t\t\t.tapAsync(THEME_NAME, this._alterAssetTags.bind(this));\n\t}\n\n\tapply(compiler) {\n\t\tthis._buildThemeFiles(compiler);\n\n\t\tcompiler.hooks\n\t\t\t.environment\n\t\t\t.tap(THEME_NAME, () => {\n\t\t\t\tconst sourceMap = this.options.sourceMap || false;\n\n\t\t\t\tcompiler.options.module.rules.push({\n\t\t\t\t\ttest: /\\.(js|jsx|ts|tsx)$/,\n\t\t\t\t\tloader: resolve(__dirname, 'Loader.js'),\n\t\t\t\t\tenforce: 'pre',\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tthemes: this._themes,\n\t\t\t\t\t\tthemeNames: this._themeNames\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tif (this.options.skipLoaders !== true) {\n\t\t\t\t\tthis._addMiniCssExtractPlugin(compiler, this.options.filename);\n\t\t\t\t\tcompiler.options.module.rules.push({\n\t\t\t\t\t\ttest: /\\.less$/,\n\t\t\t\t\t\tuse: [MiniCssExtractPlugin.loader, {\n\t\t\t\t\t\t\tloader: 'css-loader',\n\t\t\t\t\t\t\toptions: { sourceMap }\n\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\tloader: 'postcss-loader',\n\t\t\t\t\t\t\toptions: {\n\t\t\t\t\t\t\t\tpostcssOptions: { config: './' },\n\t\t\t\t\t\t\t\tsourceMap\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\tloader: 'less-loader',\n\t\t\t\t\t\t\toptions: { sourceMap }\n\t\t\t\t\t\t}]\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tthis._addChunks(compiler);\n\t\t\t});\n\n\t\tif (this._hasHtmlWebpackPlugin(compiler)) {\n\t\t\tcompiler.hooks.compilation\n\t\t\t\t.tap(THEME_NAME, this._onCompile.bind(this));\n\t\t}\n\t}\n}\n\nmodule.exports = ThemesPlugin;\n"]}