-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
50 lines (41 loc) · 1.4 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
// Rewrite webpack config if needed, aka "eject"
const { join } = require('path');
const { DefinePlugin } = require('webpack');
const configs = require('sp-build-tasks/dist/webpack/config/v2');
require('dotenv').config();
const defineOptions = Object.assign(
// Options from ./config/app.json are passed to Define plugin
{
APP_CONFIG: JSON.stringify(
require(join(process.cwd(), process.env.APP_JSON || './config/app.json'))
),
SPPP_ASSETS_LOCATION: JSON.stringify('SPWeb')
},
// All environment variables which start with "SPPP_" are passed to Define plugin
Object.keys(process.env).filter(key => key.indexOf('SPPP_') === 0).reduce((res, key) => {
res[key] = JSON.stringify(process.env[key]);
return res;
}, {})
);
configs.forEach(config => {
delete config.output.publicPath; // use dynamic __webpack_public_path__
// Define plugin
config.plugins = config.plugins || [];
config.plugins.push(new DefinePlugin(defineOptions));
// Exclude "heavy" 3rd parties
config.externals = Object.assign(config.externals || {}, {
'@pnp/sp': 'pnp',
'@pnp/odata': 'pnp',
'@pnp/logging': 'pnp',
'@pnp/common': 'pnp',
'@pnp/graph': 'pnp',
'@pnp/pnpjs': 'pnp',
'office-ui-fabric-react': 'Fabric',
'react': 'React',
'react-dom': 'ReactDOM',
'moment': 'moment',
'bootstrap': 'bootstrap',
'jquery': 'jQuery'
});
});
module.exports = configs;