summaryrefslogtreecommitdiff
path: root/electron/service/config/css.js
diff options
context:
space:
mode:
authorrejbasket <39080670+rejbasket@users.noreply.github.com>2023-05-22 22:33:19 +0200
committerGitHub <noreply@github.com>2023-05-22 22:33:19 +0200
commitef6f6580df6e8fbce913eecc1fe7e0f8caf1315b (patch)
treec1119a5d1affd44ad27e60cc6981ac98534c518d /electron/service/config/css.js
parentda54f104e6bf5d0e98f7479cf1d060c76e0b01f2 (diff)
Update electron version to v14.2.9 (#2214)
Authored-by: rejbasket Co-authored-by: Kaalleen Co-authored-by: Lex Neva
Diffstat (limited to 'electron/service/config/css.js')
-rw-r--r--electron/service/config/css.js72
1 files changed, 72 insertions, 0 deletions
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(),
+ },
+}