forked from cerner/terra-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
98 lines (94 loc) · 2.89 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const path = require('path');
const { merge } = require('webpack-merge');
const WebpackConfigTerra = require('@cerner/webpack-config-terra');
const fs = require('fs');
const TerraDevSite = require('./packages/terra-dev-site/src/webpack/plugin/TerraDevSite');
const html = fs.readFileSync(require.resolve('./tests/terra-dev-site/head.html'), 'utf8');
const devSiteConfig = (env = {}, argv = { p: false }) => ({
// temporary fix to enable live reloading.
target: argv.p || argv.mode === 'production' ? 'browserslist' : 'web',
plugins: [
new TerraDevSite({
defaultLocale: env.defaultLocale,
excludeChunks: ['terra-application-test/index'],
}),
new TerraDevSite({
pathPrefix: 'extended',
contentDirectory: 'dev-site-extended-test',
primaryNavigationItems: [{
path: '/home',
label: 'Home',
contentExtension: 'home',
additionalContent: [
{
label: 'Home',
filePath: path.resolve(process.cwd(), 'packages', 'terra-dev-site', 'README.md'),
},
],
}, {
path: '/extended',
label: 'Extended',
contentExtension: 'extended',
}, {
path: '/dev_tools',
label: 'Developer Tools',
contentExtension: 'tool',
}, {
path: '/single-page-test',
label: 'Single Page Test',
contentExtension: 'spt',
}, {
path: '/secondary-nav-test',
label: 'Secondary Nav Test',
contentExtension: 'snt',
}, {
path: '/folder-first',
label: 'Folder First Test',
contentExtension: 'ff',
}, {
path: '/empty',
label: 'Empty',
contentExtension: 'empty',
}, {
path: '/components',
label: 'Components',
contentExtension: 'doc',
}, {
path: '/test',
label: 'Test',
contentExtension: 'test',
}],
titleConfig: {
title: 'Terra Dev Site - Extended',
},
additionalSearchDirectories: [
path.resolve(process.cwd(), 'packages', 'terra-application-docs', 'lib', 'additionalSearchDirectory'),
],
headHtml: [
'<script> console.log("Inline head html script") </script>',
html,
],
extensionItems: [
{
iconPath: 'terra-icon/lib/icon/IconAllergy',
key: 'terra-application-docs.test-extension',
text: 'Test Extension',
modalFilePath: path.resolve(process.cwd(), 'tests', 'terra-dev-site', 'test-extension', 'TestExtension'),
},
],
excludeChunks: ['terra-application-test/index'],
}),
],
resolve: {
extensions: ['.jst'],
},
});
const mergedConfig = (env, argv) => (
merge(WebpackConfigTerra(env, argv), devSiteConfig())
);
module.exports = (env, argv) => {
const config = mergedConfig(env, argv);
// Brittle
config.module.rules[0].oneOf[0].test = /\.(jsx|js|jst)$/;
return config;
};