forked from wagtail/wagtail-localize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (81 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
76
77
78
79
80
81
82
/* eslint @typescript-eslint/no-var-requires: "off" */
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
main: './wagtail_localize/static_src/main.tsx',
'component-form':
'./wagtail_localize/static_src/component_form/main.tsx',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
{
test: /\.(png|jpg|gif)$/,
use: ['file-loader'],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve(
__dirname,
'wagtail_localize/static_src/component_form',
'main.css'
),
to: path.resolve(
__dirname,
'wagtail_localize/static/wagtail_localize/css',
'wagtail-localize-component-form.css'
),
},
{
from: path.resolve(
__dirname,
'wagtail_localize/static_src/editor',
'main.css'
),
to: path.resolve(
__dirname,
'wagtail_localize/static/wagtail_localize/css',
'wagtail-localize-editor-form.css'
),
},
],
}),
],
externals: {
/* These are provided by Wagtail */
react: 'React',
'react-dom': 'ReactDOM',
gettext: 'gettext',
},
output: {
path: path.resolve(
__dirname,
'wagtail_localize/static/wagtail_localize/js'
),
filename: (pathData) => {
return pathData.chunk.name === 'main'
? 'wagtail-localize.js'
: 'wagtail-localize-[name].js';
},
},
};