forked from Automattic/jetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
83 lines (79 loc) · 2.13 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
/**
* External dependencies
*/
const getBaseWebpackConfig = require( '@automattic/calypso-build/webpack.config.js' );
const path = require( 'path' );
const StaticSiteGeneratorPlugin = require( 'static-site-generator-webpack-plugin' );
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const isDevelopment = process.env.NODE_ENV !== 'production';
const baseWebpackConfig = getBaseWebpackConfig(
{ WP: false },
{
entry: {}, // We'll override later
'output-filename': '[name].js',
'output-path': path.join( __dirname, '_inc', 'build' ),
}
);
const sharedWebpackConfig = {
...baseWebpackConfig,
resolve: {
...baseWebpackConfig.resolve,
modules: [ path.resolve( __dirname, '_inc/client' ), 'node_modules' ],
},
node: {
fs: 'empty',
process: true,
},
devtool: isDevelopment ? 'source-map' : false,
};
// We export two configuration files: One for admin.js, and one for static.jsx. The latter produces pre-rendered HTML.
module.exports = [
{
...sharedWebpackConfig,
// Entry points point to the javascript module
// that is used to generate the script file.
// The key is used as the name of the script.
entry: { admin: path.join( __dirname, './_inc/client/admin.js' ) },
plugins: [
...sharedWebpackConfig.plugins,
new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ),
],
},
{
...sharedWebpackConfig,
// Entry points point to the javascript module
// that is used to generate the script file.
// The key is used as the name of the script.
entry: { static: path.join( __dirname, './_inc/client/static.jsx' ) },
output: {
...sharedWebpackConfig.output,
pathinfo: true,
libraryTarget: 'commonjs2',
},
plugins: [
...sharedWebpackConfig.plugins,
new StaticSiteGeneratorPlugin( {
globals: {
window: {
Initial_State: {
dismissedNotices: [],
connectionStatus: {
offlineMode: {
isActive: false,
},
},
userData: {
currentUser: {
permissions: {},
},
},
licensing: {
error: '',
},
},
},
},
} ),
],
},
];