diff options
author | Grigorii K. Shartsev <me@shgk.me> | 2023-07-26 15:29:24 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2023-08-18 15:16:28 +0200 |
commit | 06cdf9a54e53c8dd7f7784a36e1da1eea979f72a (patch) | |
tree | 904324a9e47151938c18f9f3a61a68de7cb975bf /webpack.common.config.js | |
parent | dd82801c026cea457906ad4e06e7cbf0259a570b (diff) |
build: use ESBuild for transpiling and minimizing in Webpack
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Diffstat (limited to 'webpack.common.config.js')
-rw-r--r-- | webpack.common.config.js | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/webpack.common.config.js b/webpack.common.config.js index b64cce5e2..72456490e 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -20,28 +20,48 @@ */ const BabelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except') +const { mergeWithRules } = require('webpack-merge') const nextcloudWebpackRules = require('@nextcloud/webpack-vue-config/rules') -// Edit JS rule -nextcloudWebpackRules.RULE_JS.exclude = BabelLoaderExcludeNodeModulesExcept([ - '@nextcloud/event-bus', - 'ansi-regex', - 'fast-xml-parser', - 'hot-patcher', - 'nextcloud-vue-collections', - 'semver', - 'strip-ansi', - 'tributejs', - 'webdav', -]) - -module.exports = { +// Replace rules with the same modules +module.exports = mergeWithRules({ + module: { + rules: { + test: 'match', + loader: 'replace', + options: 'replace', + }, + }, +})({ + module: { + // Reuse @nextcloud/webpack-vue-config/rules + rules: Object.values(nextcloudWebpackRules), + }, +}, +{ module: { rules: [ - // Reuse @nextcloud/webpack-vue-config/rules - ...Object.values(nextcloudWebpackRules), - + { + 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', + }, + exclude: BabelLoaderExcludeNodeModulesExcept([ + '@nextcloud/event-bus', + 'ansi-regex', + 'fast-xml-parser', + 'hot-patcher', + 'nextcloud-vue-collections', + 'semver', + 'strip-ansi', + 'tributejs', + 'webdav', + ]), + }, { test: /\.wasm$/i, type: 'asset/resource', @@ -56,4 +76,4 @@ module.exports = { }, ], }, -} +}) |