From ef6f6580df6e8fbce913eecc1fe7e0f8caf1315b Mon Sep 17 00:00:00 2001 From: rejbasket <39080670+rejbasket@users.noreply.github.com> Date: Mon, 22 May 2023 22:33:19 +0200 Subject: Update electron version to v14.2.9 (#2214) Authored-by: rejbasket Co-authored-by: Kaalleen Co-authored-by: Lex Neva --- electron/service/config/css.js | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 electron/service/config/css.js (limited to 'electron/service/config/css.js') diff --git a/electron/service/config/css.js b/electron/service/config/css.js new file mode 100644 index 00000000..3fb5893e --- /dev/null +++ b/electron/service/config/css.js @@ -0,0 +1,72 @@ +'use strict' + +const MiniCssExtractPlugin = require('mini-css-extract-plugin') + +const isProd = process.env.NODE_ENV === 'production' + +const plugins = [] +if (isProd) { + const filename = 'css/[name].[contenthash:8].css' + + plugins.push( + new MiniCssExtractPlugin({ + filename, + chunkFilename: filename, + }) + ) +} + +const genStyleRules = () => { + const cssLoader = { + loader: 'css-loader', + options: { + // how many loaders before css-loader should be applied to [@import]ed resources. + // stylePostLoader injected by vue-loader + postcss-loader + importLoaders: 1 + 1, + esModule: false, // css-loader using ES Modules as default in v4, but vue-style-loader support cjs only. + }, + } + const postcssLoader = { + loader: 'postcss-loader', + options: { + postcssOptions: { + plugins: [require('autoprefixer')] + }, + }, + } + const extractPluginLoader = { + loader: MiniCssExtractPlugin.loader, + } + const vueStyleLoader = { + loader: 'vue-style-loader', + } + + function createCSSRule(test, loader, loaderOptions) { + const loaders = [cssLoader, postcssLoader] + + if (isProd) { + loaders.unshift(extractPluginLoader) + } else { + loaders.unshift(vueStyleLoader) + } + + if (loader) { + loaders.push({ loader, options: loaderOptions }) + } + + return { test, use: loaders } + } + + return [ + createCSSRule(/\.css$/), + createCSSRule(/\.p(ost)?css$/), + createCSSRule(/\.scss$/, 'sass-loader') + ] +} + +module.exports = { + plugins, + module: { + rules: genStyleRules(), + }, +} -- cgit v1.2.3