-
Notifications
You must be signed in to change notification settings - Fork 27
/
webpack.prod.js
executable file
·148 lines (144 loc) · 5.25 KB
/
webpack.prod.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
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const standaloneConfig = merge(common, {
mode: 'production',
entry: {
'Editor': './src/adapter/index.tsx',
'Extensions': './src/extensions/index.tsx',
'Base': './src/extensions/base.tsx',
'Code': './src/extensions/code/index.tsx',
'Cmbed': './src/extensions/embed/index.tsx',
'Image': './src/extensions/image/index.tsx',
'Link': './src/extensions/link/index.tsx',
'Table': './src/extensions/table/index.tsx',
'Blockquote': './src/extensions/blockquote.tsx',
'BulletList': './src/extensions/bullet-list.tsx',
'CustomBlock': './src/extensions/custom-block.tsx',
'CustomMark': './src/extensions/custom-mark.tsx',
'DefaultKeys': './src/extensions/default-keys.tsx',
'DefaultPlugins': './src/extensions/default-plugins.tsx',
'Emphasis': './src/extensions/emphasis.tsx',
'Heading1': './src/extensions/heading1.tsx',
'Heading2': './src/extensions/heading2.tsx',
'Heading3': './src/extensions/heading3.tsx',
'Heading4': './src/extensions/heading4.tsx',
'Heading5': './src/extensions/heading5.tsx',
'Heading6': './src/extensions/heading6.tsx',
'ListItem': './src/extensions/list-item.tsx',
'MoveDown': './src/extensions/move-down.tsx',
'MoveUp': './src/extensions/move-up.tsx',
'OrderedList': './src/extensions/ordered-list.tsx',
'Paragraph': './src/extensions/paragraph.tsx',
'Strike': './src/extensions/strike.tsx',
'Strong': './src/extensions/strong.tsx',
'Trash': './src/extensions/trash.tsx',
'Underline': './src/extensions/underline.tsx',
},
output: {
library: {
name: ['SmartBlock', '[name]'],
type: 'umd',
export: 'default',
},
path: path.resolve(__dirname, 'dist/standalone'),
filename: (data) => {
if (data.chunk.name === 'Editor') {
return 'index.js'
}
if (data.chunk.name === 'Extensions') {
return 'extensions/index.js';
}
return `extensions/${data.chunk.name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()}.js`;
},
},
});
const defaultExportConfig = merge(common, {
mode: 'production',
entry: {
'SmartBlock': './src/components/smartblock.tsx',
'Extensions': './src/extensions/index.tsx',
'Base': './src/extensions/base.tsx',
'Code': './src/extensions/code/index.tsx',
'Cmbed': './src/extensions/embed/index.tsx',
'Image': './src/extensions/image/index.tsx',
'Link': './src/extensions/link/index.tsx',
'Table': './src/extensions/table/index.tsx',
'Blockquote': './src/extensions/blockquote.tsx',
'BulletList': './src/extensions/bullet-list.tsx',
'CustomBlock': './src/extensions/custom-block.tsx',
'CustomMark': './src/extensions/custom-mark.tsx',
'DefaultKeys': './src/extensions/default-keys.tsx',
'DefaultPlugins': './src/extensions/default-plugins.tsx',
'Emphasis': './src/extensions/emphasis.tsx',
'Heading1': './src/extensions/heading1.tsx',
'Heading2': './src/extensions/heading2.tsx',
'Heading3': './src/extensions/heading3.tsx',
'Heading4': './src/extensions/heading4.tsx',
'Heading5': './src/extensions/heading5.tsx',
'Heading6': './src/extensions/heading6.tsx',
'ListItem': './src/extensions/list-item.tsx',
'MoveDown': './src/extensions/move-down.tsx',
'MoveUp': './src/extensions/move-up.tsx',
'OrderedList': './src/extensions/ordered-list.tsx',
'Paragraph': './src/extensions/paragraph.tsx',
'Strike': './src/extensions/strike.tsx',
'Strong': './src/extensions/strong.tsx',
'Trash': './src/extensions/trash.tsx',
'Underline': './src/extensions/underline.tsx',
},
output: {
library: {
name: '[name]',
type: 'umd',
export: 'default',
},
path: path.resolve(__dirname, 'dist/umd'),
filename: (data) => {
if (data.chunk.name === 'SmartBlock') {
return 'components/smartblock.js';
}
if (data.chunk.name === 'Extensions') {
return 'extensions/index.js';
}
return `extensions/${data.chunk.name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()}.js`;
},
globalObject: 'this',
},
externals: {
react: 'react',
'react-dom': 'react-dom',
},
});
const namedExportConfig = merge(common, {
mode: 'production',
entry: {
index: './src/index.tsx',
'pm/commands': './src/pm/commands/index.ts',
'pm/gapcursor': './src/pm/gapcursor/index.ts',
'pm/history': './src/pm/history/index.ts',
'pm/inputrules': './src/pm/inputrules/index.ts',
'pm/keymap': './src/pm/keymap/index.ts',
'pm/model': './src/pm/model/index.ts',
'pm/schema-list': './src/pm/schema-list/index.ts',
'pm/state': './src/pm/state/index.ts',
'pm/tables': './src/pm/tables/index.ts',
'pm/transform': './src/pm/transform/index.ts',
'pm/utils': './src/pm/utils/index.ts',
'pm/view': './src/pm/view/index.ts',
},
output: {
library: {
name: ['SmartBlock'],
type: 'umd',
},
path: path.resolve(__dirname, 'dist/umd'),
filename: (data) => `${data.chunk.name.toLowerCase()}.js`,
globalObject: 'this',
},
externals: {
react: 'react',
'react-dom': 'react-dom',
},
});
module.exports = [standaloneConfig, defaultExportConfig, namedExportConfig];