-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgreenwood.config.js
87 lines (81 loc) · 2.31 KB
/
greenwood.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
import { greenwoodPluginGoogleAnalytics } from '@greenwood/plugin-google-analytics';
import { greenwoodPluginTypeScript } from '@greenwood/plugin-typescript';
import { greenwoodPluginPostCss } from '@greenwood/plugin-postcss';
import analyze from 'rollup-plugin-analyzer';
import { visualizer } from 'rollup-plugin-visualizer';
import dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';
import { ResourceInterface } from '@greenwood/cli/src/lib/resource-interface.js';
class ProcessEnvReplaceResource extends ResourceInterface {
constructor(compilation) {
super();
this.compilation = compilation;
}
async shouldIntercept(url) {
return url.pathname.endsWith('redux.mjs');
}
async intercept(url, request, response) {
const body = await response.text();
const env = process.env.__GWD_COMMAND__ === 'develop' ? 'development' : 'production';
const contents = body.replace(/process.env.NODE_ENV/g, `"${env}"`);
return new Response(contents, {
headers: new Headers({
'Content-Type': 'text/javascript'
})
});
}
}
export default {
optimization: 'inline',
devServer: {
proxy: {
'/api': 'https://www.analogstudios.net'
}
},
polyfills: {
importAttributes: ['css', 'json']
},
plugins: [
greenwoodPluginPostCss(),
greenwoodPluginTypeScript(),
// https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications
greenwoodPluginGoogleAnalytics({
analyticsId: 'UA-69272660-1'
}),
{
type: 'rollup',
name: 'rollup-plugin-import-vars',
provider: () => {
return [
dynamicImportVariables.default()
];
}
}, {
type: 'rollup',
name: 'rollup-plugin-analyzer',
provider: () => {
return [
analyze({
summaryOnly: true,
filter: (module) => {
return !module.id.endsWith('.html');
}
})
];
}
}, {
type: 'rollup',
name: 'rollup-plugin-visualizer',
provider: () => {
return [
visualizer({
filename: 'reports/stats.html'
})
];
}
}, {
type: 'resource',
name: 'process-env-replace',
provider: (compilation) => new ProcessEnvReplaceResource(compilation)
}
]
};