Skip to content

Commit

Permalink
chore(build): use ESBuild in Webpack
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed Jul 26, 2023
1 parent b684c60 commit 4acb8b3
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const path = require('node:path')

const { EsbuildPlugin } = require('esbuild-loader')
const webpack = require('webpack')
const { merge } = require('webpack-merge')
const { mergeWithRules } = require('webpack-merge')

const nextcloudWebpackConfig = require('@nextcloud/webpack-vue-config')

Expand All @@ -10,7 +11,20 @@ const commonWebpackConfig = require('./webpack.common.config.js')
// Rules from @nextcloud/webpack-vue-config/rules already added by commonWebpackConfig
nextcloudWebpackConfig.module.rules = []

module.exports = merge(nextcloudWebpackConfig, commonWebpackConfig, {
const talkWebMerge = mergeWithRules({
optimization: {
minimizer: 'replace',
},
module: {
rules: {
test: 'match',
loader: 'replace',
options: 'replace',
},
},
})

module.exports = talkWebMerge(nextcloudWebpackConfig, commonWebpackConfig, {
entry: {
'admin-settings': path.join(__dirname, 'src', 'mainAdminSettings.js'),
collections: path.join(__dirname, 'src', 'collections.js'),
Expand All @@ -32,6 +46,28 @@ module.exports = merge(nextcloudWebpackConfig, commonWebpackConfig, {
assetModuleFilename: '[name][ext]?v=[contenthash]',
},

module: {
rules: [
{
test: /\.js$/,
loader: 'esbuild-loader',
options: {
// Implicitly set as JS loader for only JS parts of Vue SFCs will be transpiled
loader: 'js',
target: 'es2020',
},
},
],
},

optimization: {
minimizer: [
new EsbuildPlugin({
target: 'es2020',
}),
],
},

plugins: [
new webpack.DefinePlugin({ IS_DESKTOP: false }),
],
Expand Down

0 comments on commit 4acb8b3

Please sign in to comment.