-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvite.config.js
54 lines (50 loc) · 1.42 KB
/
vite.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
/*
* Copyright 2020 Harness Inc. All rights reserved.
* Use of this source code is governed by the PolyForm Shield 1.0.0 license
* that can be found in the licenses directory at the root of this repository, also available at
* https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
*/
const path = require('path')
const _ = require('lodash')
const package = require('./package.json')
const globals = require('../globals.json')
const dts = require('vite-plugin-dts')
const external = Object.keys(package.peerDependencies)
external.forEach(dep => {
if (!_.has(globals, dep)) {
console.log(`Entry for "${dep}" not found in globals.json`)
process.exit(1)
}
})
/**
* @type {import('vite').UserConfig}
*/
const config = {
build: {
lib: {
entry: path.resolve(__dirname, 'src'),
name: 'HarnessCore'
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external,
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: _.pick(globals, external)
}
}
},
css: {
modules: {
scopeBehaviour: 'local',
generateScopedName: (name, filename, _css) => {
const basename = path.basename(filename).replace(/\.module\.css?.*/, '')
return `${basename}--${name}`
}
}
},
plugins: [dts()]
}
module.exports = config