-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
73 lines (67 loc) · 2.28 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
const {
configureWebpack,
graphQL: { getMediaURL, getStoreConfigData, getPossibleTypes }
} = require('@magento/pwa-buildpack');
const { DefinePlugin } = require('webpack');
const HTMLWebpackPlugin = require('html-webpack-plugin');
module.exports = async env => {
const mediaUrl = await getMediaURL();
const storeConfigData = await getStoreConfigData();
global.MAGENTO_MEDIA_BACKEND_URL = mediaUrl;
global.LOCALE = storeConfigData.locale.replace('_', '-');
const possibleTypes = await getPossibleTypes();
const config = await configureWebpack({
context: __dirname,
vendor: [
'@apollo/client',
'apollo-cache-persist',
'informed',
'react',
'react-dom',
'react-feather',
'react-redux',
'react-router-dom',
'redux',
'redux-actions',
'redux-thunk'
],
special: {
'react-feather': {
esModules: true
}
},
env
});
/**
* configureWebpack() returns a regular Webpack configuration object.
* You can customize the build by mutating the object here, as in
* this example. Since it's a regular Webpack configuration, the object
* supports the `module.noParse` option in Webpack, documented here:
* https://webpack.js.org/configuration/module/#modulenoparse
*/
config.module.noParse = [/braintree\-web\-drop\-in/];
config.plugins = [
...config.plugins,
new DefinePlugin({
/**
* Make sure to add the same constants to
* the globals object in jest.config.js.
*/
POSSIBLE_TYPES: JSON.stringify(possibleTypes),
STORE_NAME: JSON.stringify('Venia'),
STORE_VIEW_LOCALE: JSON.stringify(global.LOCALE),
STORE_VIEW_CODE: process.env.STORE_VIEW_CODE
? JSON.stringify(process.env.STORE_VIEW_CODE)
: JSON.stringify(storeConfigData.code)
}),
new HTMLWebpackPlugin({
filename: 'index.html',
template: './template.html',
minify: {
collapseWhitespace: true,
removeComments: true
}
})
];
return config;
};