forked from diplodoc-platform/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
66 lines (62 loc) · 2.42 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
const {resolve} = require('path');
module.exports = [
{
mode: 'development',
target: 'web',
entry: './src/app/index.tsx',
output: {
path: resolve(__dirname, 'build'),
filename: 'app.js',
},
resolve: {
alias: {
react: require.resolve('react'),
},
extensions: ['.tsx', '.ts', '.js', '.scss'],
},
module: {
rules: [
{
test: /\.[tj]sx?$/,
use: ['babel-loader'],
include: [
resolve(__dirname, 'src'),
require.resolve('@diplodoc/mermaid-extension'),
],
}, {
test: /\.s?css$/,
use: [
{
loader: 'style-loader',
options: {
insert: function insertBeforeAt(element) {
/* eslint-env browser */
const parent = document.querySelector('head');
const target = document.querySelector('#custom-style');
const lastInsertedElement =
window._lastElementInsertedByStyleLoader;
if (!lastInsertedElement) {
parent.insertBefore(element, target);
} else if (lastInsertedElement.nextSibling) {
parent.insertBefore(
element,
lastInsertedElement.nextSibling,
);
} else {
parent.appendChild(element);
}
window._lastElementInsertedByStyleLoader = element;
},
},
},
{loader: 'css-loader'},
{loader: 'sass-loader'},
],
}, {
test: /\.svg$/,
loader: 'react-svg-loader',
},
],
},
},
];