This repository has been archived by the owner on Jun 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
webpack.config.js
59 lines (53 loc) · 2.51 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
const path = require('path');
const outputDir = path.resolve(__dirname, './dist');
const {SchemaToDefaultsPlugin} = require('openfin-service-config/plugins/SchemaToDefaultsPlugin');
const {SchemaToTypeScriptPlugin} = require('openfin-service-config/plugins/SchemaToTypeScriptPlugin');
/**
* Import the webpack tools from openfin-service-tooling
*/
const webpackTools = require('openfin-service-tooling').webpackTools;
const schemaRoot = path.resolve(__dirname, './res/provider/config');
const schemaOutput = path.resolve(__dirname, './gen/provider/config');
const defaultsOutput = path.resolve(__dirname, './gen/provider/config/defaults.json');
/**
* Webpack plugin to generate a static JSON file that contains the default value of every input schema.
*
* Any top-level 'rules' object will be stripped-out of the generated JSON, as the 'rules' property has
* special significance and isn't a part of the actual service-specific set of config options.
*
* Generated code is placed inside a top-level 'gen' folder, whose structure mirrors that of
* the 'src', 'res' and 'test' folders.
*/
const schemaDefaultsPlugin = new SchemaToDefaultsPlugin({
outputPath: defaultsOutput,
input: `${schemaRoot}/fdc3-config.schema.json`
});
/**
* Webpack plugin to generate TypeScript definitions from one or more JSON schema files.
*
* Generated code is placed inside a top-level 'gen' folder, whose structure mirrors that of
* the 'src', 'res' and 'test' folders.
*/
const schemaTypesPlugin = new SchemaToTypeScriptPlugin({
schemaRoot,
outputPath: schemaOutput,
input: [
`${schemaRoot}/fdc3-config.schema.json`
]
});
/**
* Modules to be exported
*/
module.exports = [
webpackTools.createConfig(`${outputDir}/client`, './src/client/main.ts', {minify: false, isLibrary: true, libraryName: 'fdc3'}, webpackTools.versionPlugin),
webpackTools.createConfig(`${outputDir}/client`, './src/client/main.ts', {
minify: true, isLibrary: true, libraryName: 'fdc3', outputFilename: 'openfin-fdc3'
}, webpackTools.versionPlugin),
webpackTools.createConfig(`${outputDir}/provider`, './src/provider/index.ts', undefined, webpackTools.manifestPlugin, webpackTools.versionPlugin, schemaDefaultsPlugin, schemaTypesPlugin),
webpackTools.createConfig(`${outputDir}/provider/ui`, {
'resolver': './src/provider/view/ResolverApp.tsx'
}, undefined, webpackTools.versionPlugin),
webpackTools.createConfig(`${outputDir}/demo`, {
app: './src/demo/index.tsx'
}, undefined, webpackTools.versionPlugin)
];