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
This commit is contained in:
absidue 2022-09-02 15:19:06 +02:00 committed by GitHub
parent 44c010c5fe
commit 9961183c1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 80 deletions

View File

@ -68,13 +68,9 @@ if (isDevMode) {
config.plugins.push( config.plugins.push(
new CopyWebpackPlugin({ new CopyWebpackPlugin({
patterns: [ patterns: [
{
from: path.join(__dirname, '../static/pwabuilder-sw.js'),
to: path.join(__dirname, '../dist/web/pwabuilder-sw.js'),
},
{ {
from: path.join(__dirname, '../static'), from: path.join(__dirname, '../static'),
to: path.join(__dirname, '../dist/web/static'), to: path.join(__dirname, '../dist/static'),
globOptions: { globOptions: {
dot: true, dot: true,
ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'], ignore: ['**/.*', '**/pwabuilder-sw.js', '**/dashFiles/**', '**/storyboards/**'],
@ -96,11 +92,7 @@ if (isDevMode) {
ignore: ['**/.*'], ignore: ['**/.*'],
}, },
}, },
] ]
}
),
new webpack.LoaderOptionsPlugin({
minimize: true,
}) })
) )
} }

View File

@ -2,7 +2,6 @@ const path = require('path')
const webpack = require('webpack') const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin') const VueLoaderPlugin = require('vue-loader/lib/plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { const {
@ -54,11 +53,8 @@ const config = {
use: [ use: [
{ {
loader: MiniCssExtractPlugin.loader, loader: MiniCssExtractPlugin.loader,
options: {},
},
{
loader: 'css-loader',
}, },
'css-loader',
{ {
loader: 'sass-loader', loader: 'sass-loader',
options: { options: {
@ -75,8 +71,7 @@ const config = {
test: /\.css$/, test: /\.css$/,
use: [ use: [
{ {
loader: MiniCssExtractPlugin.loader, loader: MiniCssExtractPlugin.loader
options: {},
}, },
'css-loader', 'css-loader',
], ],
@ -153,53 +148,6 @@ if (isDevMode) {
__static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`, __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 module.exports = config

View File

@ -46,11 +46,8 @@ const config = {
use: [ use: [
{ {
loader: MiniCssExtractPlugin.loader, loader: MiniCssExtractPlugin.loader,
options: {},
},
{
loader: 'css-loader',
}, },
'css-loader',
{ {
loader: 'sass-loader', loader: 'sass-loader',
options: { options: {
@ -67,8 +64,7 @@ const config = {
test: /\.css$/, test: /\.css$/,
use: [ use: [
{ {
loader: MiniCssExtractPlugin.loader, loader: MiniCssExtractPlugin.loader
options: {},
}, },
'css-loader', 'css-loader',
], ],
@ -183,11 +179,7 @@ if (isDevMode) {
ignore: ['**/.*'], ignore: ['**/.*'],
}, },
}, },
] ]
}
),
new webpack.LoaderOptionsPlugin({
minimize: true,
}) })
) )
} }

View File

@ -63,11 +63,7 @@ const config = {
if (isDevMode) { if (isDevMode) {
// any dev only config // any dev only config
} else { } else {
config.plugins.push( // any producation only config
new webpack.LoaderOptionsPlugin({
minimize: true,
})
)
} }
module.exports = config module.exports = config