From 9961183c1bcd2fce8ba65ef08a355d27640deb92 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Fri, 2 Sep 2022 15:19:06 +0200 Subject: [PATCH] Only generate the web assets directory during web builds (#2528) * Webpack 5 optimises productions builds by default, no need for the LoaderOptionsPlugin * Only create web assets during web build --- _scripts/webpack.main.config.js | 12 ++----- _scripts/webpack.renderer.config.js | 56 ++--------------------------- _scripts/webpack.web.config.js | 14 ++------ _scripts/webpack.workers.config.js | 6 +--- 4 files changed, 8 insertions(+), 80 deletions(-) diff --git a/_scripts/webpack.main.config.js b/_scripts/webpack.main.config.js index d7316fd7..39919eb5 100644 --- a/_scripts/webpack.main.config.js +++ b/_scripts/webpack.main.config.js @@ -68,13 +68,9 @@ if (isDevMode) { config.plugins.push( new CopyWebpackPlugin({ patterns: [ - { - from: path.join(__dirname, '../static/pwabuilder-sw.js'), - to: path.join(__dirname, '../dist/web/pwabuilder-sw.js'), - }, { from: path.join(__dirname, '../static'), - to: path.join(__dirname, '../dist/web/static'), + to: path.join(__dirname, '../dist/static'), globOptions: { dot: true, ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], @@ -96,11 +92,7 @@ if (isDevMode) { ignore: ['**/.*'], }, }, - ] - } - ), - new webpack.LoaderOptionsPlugin({ - minimize: true, + ] }) ) } diff --git a/_scripts/webpack.renderer.config.js b/_scripts/webpack.renderer.config.js index 4f73ce06..9ed57e5f 100644 --- a/_scripts/webpack.renderer.config.js +++ b/_scripts/webpack.renderer.config.js @@ -2,7 +2,6 @@ const path = require('path') const webpack = require('webpack') const HtmlWebpackPlugin = require('html-webpack-plugin') const VueLoaderPlugin = require('vue-loader/lib/plugin') -const CopyWebpackPlugin = require('copy-webpack-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const { @@ -54,11 +53,8 @@ const config = { use: [ { loader: MiniCssExtractPlugin.loader, - options: {}, - }, - { - loader: 'css-loader', }, + 'css-loader', { loader: 'sass-loader', options: { @@ -75,8 +71,7 @@ const config = { test: /\.css$/, use: [ { - loader: MiniCssExtractPlugin.loader, - options: {}, + loader: MiniCssExtractPlugin.loader }, 'css-loader', ], @@ -153,53 +148,6 @@ if (isDevMode) { __static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`, }) ) -} else { - config.plugins.push( - new CopyWebpackPlugin({ - patterns: [ - { - from: path.join(__dirname, '../static/pwabuilder-sw.js'), - to: path.join(__dirname, '../dist/web/pwabuilder-sw.js'), - }, - { - from: path.join(__dirname, '../static'), - to: path.join(__dirname, '../dist/web/static'), - globOptions: { - dot: true, - ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], - }, - }, - { - from: path.join(__dirname, '../static'), - to: path.join(__dirname, '../dist/static'), - globOptions: { - dot: true, - ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], - }, - }, - { - from: path.join(__dirname, '../_icons'), - to: path.join(__dirname, '../dist/web/_icons'), - globOptions: { - dot: true, - ignore: ['**/.*'], - }, - }, - { - from: path.join(__dirname, '../src/renderer/assets/img'), - to: path.join(__dirname, '../dist/web/images'), - globOptions: { - dot: true, - ignore: ['**/.*'], - }, - }, - ] - } - ), - new webpack.LoaderOptionsPlugin({ - minimize: true, - }) - ) } module.exports = config diff --git a/_scripts/webpack.web.config.js b/_scripts/webpack.web.config.js index 1b15f319..dbe06e98 100644 --- a/_scripts/webpack.web.config.js +++ b/_scripts/webpack.web.config.js @@ -46,11 +46,8 @@ const config = { use: [ { loader: MiniCssExtractPlugin.loader, - options: {}, - }, - { - loader: 'css-loader', }, + 'css-loader', { loader: 'sass-loader', options: { @@ -67,8 +64,7 @@ const config = { test: /\.css$/, use: [ { - loader: MiniCssExtractPlugin.loader, - options: {}, + loader: MiniCssExtractPlugin.loader }, 'css-loader', ], @@ -183,11 +179,7 @@ if (isDevMode) { ignore: ['**/.*'], }, }, - ] - } - ), - new webpack.LoaderOptionsPlugin({ - minimize: true, + ] }) ) } diff --git a/_scripts/webpack.workers.config.js b/_scripts/webpack.workers.config.js index 7ca42754..4c5b7a69 100644 --- a/_scripts/webpack.workers.config.js +++ b/_scripts/webpack.workers.config.js @@ -63,11 +63,7 @@ const config = { if (isDevMode) { // any dev only config } else { - config.plugins.push( - new webpack.LoaderOptionsPlugin({ - minimize: true, - }) - ) + // any producation only config } module.exports = config