-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.mjs
124 lines (118 loc) · 2.48 KB
/
webpack.config.mjs
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
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/
/* eslint-env node */
import path from 'path';
import webpack from 'webpack';
import { fileURLToPath } from 'url';
import TerserPlugin from 'terser-webpack-plugin';
import { getLastFromChangelog } from '@ckeditor/ckeditor5-dev-release-tools';
const __filename = fileURLToPath( import.meta.url );
const __dirname = path.dirname( __filename );
const LIBRARY_TO_FILE_NAMES = {
CKEditorInspector: 'inspector.js',
MiniCKEditorInspector: 'miniinspector.js'
};
export default ( env, argv ) => {
const devMode = argv.mode === 'development';
return {
mode: argv.mode || 'production',
entry: {
CKEditorInspector: path.resolve( __dirname, 'src', 'ckeditorinspector.js' ),
MiniCKEditorInspector: path.resolve( __dirname, 'src', 'minickeditorinspector.js' )
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: [
[
'@babel/react',
{
development: devMode
}
]
],
plugins: []
}
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: {
injectType: devMode ? 'styleTag' : 'singletonStyleTag',
attributes: {
'data-cke-inspector': true
}
}
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: devMode
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: devMode,
postcssOptions: {
ctx: {
cssnano: !devMode
}
}
}
}
]
},
{
test: /\.svg$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'@babel/react',
{
development: devMode
}
]
]
}
},
{
loader: 'react-svg-loader',
options: {
jsx: true
}
}
]
}
]
},
optimization: {
minimize: !devMode,
minimizer: [ new TerserPlugin() ]
},
output: {
path: path.resolve( __dirname, 'build' ),
library: '[name]',
filename: data => LIBRARY_TO_FILE_NAMES[ data.chunk.name ],
libraryTarget: 'umd',
libraryExport: 'default'
},
plugins: [
new webpack.DefinePlugin( {
CKEDITOR_INSPECTOR_VERSION: JSON.stringify( getLastFromChangelog() )
} )
]
};
};