-
Notifications
You must be signed in to change notification settings - Fork 556
/
webpack.config.js
150 lines (147 loc) · 4.59 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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
const path = require('path');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const webpack = require('webpack');
const CopyPlugin = require("copy-webpack-plugin");
module.exports = {
entry: {
standard: path.join(
__dirname,
'static',
'src',
'javascripts',
'boot.js'
),
admin: path.join(
__dirname,
'static',
'src',
'javascripts',
'bootstraps',
'admin.js'
),
// Old VideoJS embed
'videojs-embed': path.join(
__dirname,
'static',
'src',
'javascripts',
'bootstraps',
'videojs-embed.js'
),
// Video embed with native video player enhancements
'video-embed': path.join(
__dirname,
'static',
'src',
'javascripts',
'bootstraps',
'video-embed.js'
),
'youtube-embed': path.join(
__dirname,
'static',
'src',
'javascripts',
'bootstraps',
'youtube-embed.ts'
),
},
output: {
path: path.join(__dirname, 'static', 'target', 'javascripts'),
},
resolve: {
modules: [
path.join(__dirname, 'static', 'src', 'javascripts'),
path.join(__dirname, 'static', 'vendor', 'javascripts'),
'node_modules', // default location, but we're overiding above, so it needs to be explicit
],
alias: {
admin: 'projects/admin',
common: 'projects/common',
facia: 'projects/facia',
membership: 'projects/membership',
commercial: 'projects/commercial',
journalism: 'projects/journalism',
// #wp-rjs weird old aliasing from requirejs
videojs: 'video.js',
svgs: path.join(__dirname, 'static', 'src', 'inline-svgs'),
'ophan/ng': 'ophan-tracker-js',
'ophan/embed': 'ophan-tracker-js/build/ophan.embed',
lodash: 'lodash-es',
"react": "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
},
extensions: ['.js', '.ts', '.tsx', '.jsx'],
symlinks: false, // Inserted to enable linking @guardian/consent-management-platform
},
resolveLoader: {
modules: [
path.resolve(__dirname, 'dev', 'webpack-loaders'),
path.resolve(
__dirname,
'node_modules',
'@guardian',
'node_modules'
),
'node_modules',
],
},
module: {
rules: [
{
test: /\.[jt]sx?|mjs$/,
exclude: {
or: [/node_modules/, path.resolve(__dirname, 'static/vendor')],
not: [
// Include all @guardian modules, except automat-modules
/@guardian\/(?!(automat-modules|automat-contributions))/,
// Include the dynamic-import-polyfill
/dynamic-import-polyfill/,
],
},
use: [
{
loader: 'babel-loader',
},
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
]
},
{
test: /\.svg$/,
exclude: /(node_modules)/,
loader: 'svg-loader',
},
{
test: /\.(html|css)$/,
exclude: /(node_modules)/,
loader: 'raw-loader',
},
],
},
plugins: [
// Makes videosjs available to all modules in the videojs chunk.
// videojs plugins expect this object to be available globally,
// but it's sufficient to scope it at the chunk level
new webpack.ProvidePlugin({
videojs: 'videojs',
}),
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /node_modules/,
// add errors to webpack instead of warnings
failOnError: true,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
],
externals: {
xhr2: {},
},
};