-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
75 lines (71 loc) · 2.35 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
const path = require( "path" );
const LiveReloadPlugin = require('webpack-livereload-plugin');
module.exports = env => {
return {
mode: env.production ? "production" : "development",
entry: {
"post-panel": path.join(__dirname, "/assets/post-panel/index.tsx"),
"newsroom-management": path.join(__dirname, "/assets/newsroom-management/index.tsx"),
"content-viewer": path.join(__dirname, "/assets/content-viewer/index.tsx"),
"users-page": path.join(__dirname, "/assets/users-page.tsx"),
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"],
alias: {
// Make Webpack always resolve styled-components to the version of module required by us, to resolve problem caused by linked @joincivil/components including its own copy of the module (https://www.styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page):
'styled-components': path.resolve(__dirname, 'node_modules', 'styled-components'),
},
},
output: {
path: __dirname,
filename: "build/[name].build.js",
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "awesome-typescript-loader",
options: {
configFileName: path.join(__dirname, "/tsconfig.json"),
}
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: "[name].[ext]",
publicPath: "/wp-content/plugins/civil-publisher/images/",
outputPath: 'images/'
}
}
]
}
],
},
externals: {
// Reuse libraries exposed by Gutenberg:
lodash: "lodash",
moment: "moment",
jquery: "jQuery",
react: "React",
"react-dom": "ReactDOM",
},
plugins: [
env.reload ? new LiveReloadPlugin() : false,
].filter(Boolean),
devtool: env.production ? undefined : "source-map",
watch: env.watch,
watchOptions: {
// VMs don't support file watch so we can use polling instead
poll: env.vm ? 250 : undefined,
},
};
};