-
Notifications
You must be signed in to change notification settings - Fork 38
/
webpack.config.js
84 lines (83 loc) · 2.04 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
const path = require('path')
module.exports = (env, args) => ({
output: {
library: 'MathquillComponent',
libraryTarget: 'umd',
umdNamedDefine: true,
filename:
args.mode == 'production'
? 'react-mathquill.min.js'
: 'react-mathquill.js',
path: path.resolve(__dirname, 'dist/'),
},
target: 'node',
externals: {
react: 'react',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.(ttf|eot|woff|woff2|otf|svg)$/,
loader: 'file-loader',
options: {
name: 'font/[name].[ext]',
},
},
{
test: /\.css$/,
loader: 'css-loader',
},
{
test: /mathquill\.css$/,
loader: 'string-replace-loader',
options: {
search: '@font-face {(.|\n)+?}',
replace:
'@font-face {\n' +
' /* Heavy fonts have been removed */\n' +
' font-family: Symbola;\n' +
// ' src: url("font/Symbola.woff2") format("woff2"), url("font/Symbola.woff") format("woff");\n' +
// ' src: url("font/Symbola.ttf") format("truetype");\n',
'}',
flags: 'g',
},
},
{
// You can use `regexp`
// test: /example\.js/$
test: /.*mathquill\/build\/mathquill\.js$/,
use: [
{
loader: 'imports-loader',
options: {
type: 'commonjs',
imports: {
syntax: 'single',
moduleName: 'jquery',
name: '__webpack_jquery',
},
additionalCode: 'window.jQuery=__webpack_jquery;',
},
},
{
loader: 'exports-loader',
options: {
type: 'commonjs',
exports: {
syntax: 'single',
name: 'window.MathQuill',
},
},
},
],
},
],
},
})