forked from nextcloud/text
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
60 lines (51 loc) · 1.8 KB
/
webpack.config.js
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
59
60
const path = require('path')
const webpack = require('webpack')
const webpackConfig = require('@nextcloud/webpack-vue-config')
webpackConfig.entry = {
text: path.join(__dirname, 'src', 'main.js'),
files: path.join(__dirname, 'src', 'files.js'),
public: path.join(__dirname, 'src', 'public.js'),
viewer: path.join(__dirname, 'src', 'viewer.js'),
editors: path.join(__dirname, 'src', 'editor.js'),
init: path.join(__dirname, 'src', 'init.js'),
}
webpackConfig.output.chunkFilename = '[id].js?v=[contenthash]'
// The app name `text` in appinfo
// and the package name `@nextcloud/text in package.json differ.
// webpack-vue-config reads the app name from package.json.
// But for bundling we need the one from appinfo.
// Can be removed after merge of
// https://github.com/nextcloud/webpack-vue-config/pull/338
const appName = 'text'
Object.assign(webpackConfig.output, {
publicPath: path.join('/apps/', appName, '/js/'),
filename: `${appName}-[name].js?v=[contenthash]`,
devtoolNamespace: appName,
devtoolModuleFilenameTemplate(info) {
const rootDir = process.cwd()
const rel = path.relative(rootDir, info.absoluteResourcePath)
return `webpack:///${appName}/${rel}`
},
})
webpackConfig.optimization.chunkIds = 'named'
webpackConfig.optimization.splitChunks.cacheGroups = {
defaultVendors: {
test(module) {
return module.resource && module.resource.includes(`${path.sep}node_modules${path.sep}`) &&
!module.resource.includes(`${path.sep}highlight.js${path.sep}`)
},
name: 'vendors',
}
}
// webpackConfig.resolve.modules = [
// path.resolve(__dirname, 'node_modules'),
// 'node_modules'
// ]
// Fix Buffer issues
webpackConfig.plugins.push(new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}))
webpackConfig.resolve.fallback = {
buffer: require.resolve('buffer'),
}
module.exports = webpackConfig