forked from nextcloud/viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
58 lines (47 loc) · 1.37 KB
/
webpack.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* eslint-disable n/no-extraneous-import */
import fs from 'fs'
import path from 'path'
import webpack from 'webpack'
import webpackConfig from '@nextcloud/webpack-vue-config'
import webpackRules from '@nextcloud/webpack-vue-config/rules'
import BabelLoaderExcludeNodeModulesExcept from 'babel-loader-exclude-node-modules-except'
const isTesting = !!process.env.TESTING
const plyrIcons = fs.readFileSync(path.join('node_modules', 'plyr', 'dist', 'plyr.svg'), { encoding: 'utf8' })
if (isTesting) {
console.debug('TESTING MODE ENABLED')
}
// vue-plyr uses .mjs file
webpackRules.RULE_JS.test = /\.m?js$/
webpackRules.RULE_JS.exclude = BabelLoaderExcludeNodeModulesExcept([
'@nextcloud/dialogs',
'@nextcloud/event-bus',
'camelcase',
'fast-xml-parser',
'hot-patcher',
'semver',
'vue-plyr',
'webdav',
'toastify-js',
])
webpackRules.RULE_TS = {
test: /\.tsx?$/,
use: [
'babel-loader',
'ts-loader',
],
exclude: BabelLoaderExcludeNodeModulesExcept([]),
}
// Replaces rules array
webpackConfig.module.rules = Object.values(webpackRules)
// Add custom plugins
webpackConfig.plugins.push(...[
new webpack.DefinePlugin({
isTesting,
PLYR_ICONS: JSON.stringify(plyrIcons),
}),
])
// Add proper typescript support
webpackConfig.resolve.extensions = ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.vue']
// Clean dist folder
webpackConfig.output.clean = true
export default webpackConfig