-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
104 lines (99 loc) · 2.25 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const path = require('path')
const webpack = require('webpack')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const rehypeHighlight = require('rehype-highlight')
const remarkSlug = require('remark-slug')
const remarkNormalizeHeadings = require('remark-normalize-headings')
const tsLoader = {
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
const babelLoader = {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import'
]
}
}
const cssLoader = {
loader: 'typings-for-css-modules-loader',
options: {
modules: true,
namedExport: true,
camelCase: true,
localIdentName: '[folder]_[local]__[hash:base64:5]'
}
}
const mdLoader = {
loader: '@hugmanrique/react-markdown-loader',
options: {
rehypePlugins: [rehypeHighlight],
remarkPlugins: [remarkNormalizeHeadings, remarkSlug]
}
}
module.exports = {
devtool: 'inline-source-map',
entry: ['./src/index.tsx'],
output: {
path: path.join(__dirname, 'assets', 'js'),
filename: 'index.js',
publicPath: '/assets/js/'
},
resolve: {
extensions: ['*', '.md', '.css', '.js', '.jsx', '.ts', '.tsx']
},
mode: 'development',
optimization: {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false
},
module: {
rules: [
{
test: /\.svg$/,
use: [babelLoader, { loader: 'svg-react-loader' }]
},
{
test: /\.md$/,
use: [
babelLoader,
mdLoader,
{ loader: 'md-macro-loader' },
{ loader: 'toc-loader' }
]
},
{
test: /\.css$/,
enforce: 'pre',
use: [
{ loader: 'style-loader' },
cssLoader,
{ loader: 'postcss-loader' }
]
},
{
test: /\.tsx?$/,
use: [babelLoader, tsLoader]
}
]
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new webpack.HotModuleReplacementPlugin()
],
devServer: {
contentBase: __dirname,
compress: true,
hot: true,
port: 9000
},
resolveLoader: {
modules: ['node_modules', path.resolve(__dirname, 'loaders')]
}
}