forked from Automattic/wp-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.shared.js
More file actions
124 lines (122 loc) · 3.55 KB
/
webpack.shared.js
File metadata and controls
124 lines (122 loc) · 3.55 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* External Dependencies
*/
var path = require( 'path' );
var webpack = require( 'webpack' );
module.exports = {
target: 'node',
module: {
rules: [
{
test: /extensions[\/\\]index/,
exclude: path.join( __dirname, 'calypso', 'node_modules' ),
loader: path.join( __dirname, 'calypso', 'server', 'bundler', 'extensions-loader' ),
},
{
include: path.join( __dirname, 'calypso', 'client/sections.js' ),
use: {
loader: path.join( __dirname, 'calypso', 'client', 'server', 'bundler', 'sections-loader' ),
options: { forceRequire: true, onlyIsomorphic: true },
},
},
{
test: /\.html$/,
loader: 'html-loader',
},
{
test: /\.[jt]sx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
loader: 'babel-loader',
include: filepath => {
// is it one of the npm dependencies we want to transpile?
const lastIndex = filepath.lastIndexOf( '/node_modules/' );
if ( lastIndex === -1 ) {
return false;
}
return [ 'chalk', '@automattic/calypso-polyfills' ].some( pkg =>
filepath.startsWith( `/node_modules/${ pkg }/`, lastIndex )
);
},
},
{
test: /\.(sc|sa|c)ss$/,
loader: 'ignore-loader',
},
{
test: /\.(?:gif|jpg|jpeg|png|svg)$/i,
use: {
loader: 'file-loader',
options: {
name: '[name]-[hash].[ext]',
outputPath: 'images',
publicPath: '/calypso/images/',
emitFile: false,
},
},
},
],
},
node: {
__filename: true,
__dirname: true,
},
context: __dirname,
externals: [
'express',
'webpack',
'superagent',
'electron',
'component-tip',
// These are Calypso server modules we don't need, so let's not bundle them
'webpack.config',
'server/devdocs/search-index',
],
resolve: {
extensions: [ '.json', '.js', '.jsx', '.ts', '.tsx' ],
modules: [
'node_modules',
path.join( __dirname, 'calypso', 'node_modules' ),
path.join( __dirname, 'node_modules' ),
path.join( __dirname, 'calypso', 'client' ),
path.join( __dirname, 'desktop' ),
],
alias: {
config: 'server/config',
},
},
plugins: [
new webpack.NormalModuleReplacementPlugin( /^lib[\/\\]abtest$/, 'lodash/noop' ), // Depends on BOM
new webpack.NormalModuleReplacementPlugin( /^lib[\/\\]analytics$/, 'lodash/noop' ), // Depends on BOM
new webpack.NormalModuleReplacementPlugin( /^lib[\/\\]sites-list$/, 'lodash/noop' ), // Depends on BOM
new webpack.NormalModuleReplacementPlugin( /^lib[\/\\]olark$/, 'lodash/noop' ), // Depends on DOM
new webpack.NormalModuleReplacementPlugin( /^lib[\/\\]user$/, 'lodash/noop' ), // Depends on BOM
new webpack.NormalModuleReplacementPlugin(
/^lib[\/\\]post-normalizer[\/\\]rule-create-better-excerpt$/,
'lodash/noop'
), // Depends on BOM
new webpack.NormalModuleReplacementPlugin(
/^components[\/\\]seo[\/\\]reader-preview$/,
'components/empty-component'
), // Conflicts with component-closest module
new webpack.NormalModuleReplacementPlugin(
/^components[\/\\]popover$/,
'components/null-component'
), // Depends on BOM and interactions don't work without JS
new webpack.NormalModuleReplacementPlugin(
/^my-sites[\/\\]themes[\/\\]theme-upload$/,
'components/empty-component'
), // Depends on BOM
new webpack.NormalModuleReplacementPlugin(
/^client[\/\\]layout[\/\\]guided-tours[\/\\]config$/,
'components/empty-component'
), // should never be required server side
new webpack.NormalModuleReplacementPlugin(
/^components[\/\\]site-selector$/,
'components/null-component'
), // Depends on BOM
],
};