-
Notifications
You must be signed in to change notification settings - Fork 19
/
doczrc.js
138 lines (135 loc) · 4.04 KB
/
doczrc.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
import path from 'path';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import TerserJSPlugin from 'terser-webpack-plugin';
import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
import FilterWarningsPlugin from 'webpack-filter-warnings-plugin';
import pkg from './package.json';
// https://www.docz.site/docs/project-configuration
export default {
src: './example',
public: './public',
title: 'Ztopia Theme',
description: pkg.description,
theme: path.resolve(__dirname, './dist'),
typescript: false,
notUseSpecifiers: true,
htmlContext: {
head: {
links: [],
},
},
/** Control menu order */
menu: [
{ name: 'Docs', menu: ['Introduction', 'Getting Started', 'Design'] },
{ name: 'Components' },
],
filterComponents: files =>
files.filter(file => /([^d]\.(t|j)sx?)$/.test(file)),
modifyBundlerConfig: (config, isDev) => ({
...config,
module: {
...config.module,
rules: [
...config.module.rules,
// For loading user styles (using CSS modules)
{
test: /\.css$/,
include: [path.resolve(__dirname, './example')],
use: [
isDev
? {
// v0.23.1
loader: 'style-loader',
options: {
// When source map is set to true,
// CSS will be generated as stylesheet blobs.
// This is required because we should always creates separate stylesheets for user styles
// so that they will be injected properly in iframe mode.
// Plus, you will want source map during development
sourceMap: true,
},
}
: {
// v0.7.0
loader: MiniCssExtractPlugin.loader,
},
{
// v3.0.0
loader: 'css-loader',
options: {
importLoaders: 1,
// Only enable source map in development mode
sourceMap: isDev,
modules: {
mode: 'local',
localIdentName: isDev
? '[name]__[local]--[hash:base64:5]'
: '[hash:base64:5]',
},
},
},
{
// v3.0.0
loader: 'postcss-loader',
},
],
},
// For loading vendor styles (not using CSS modules)
{
test: /\.css$/,
include: [],
use: [
{
// v0.23.1
// All vendors styles must be loaded in <style> tags
loader: 'style-loader',
options: {
sourceMap: false,
},
},
{
// v3.0.0
loader: 'css-loader',
},
],
},
],
},
optimization: {
...config.optimization,
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
splitChunks: {
...config.optimization.splitChunks,
cacheGroups: {
...config.optimization.splitChunks.cacheGroups,
styles: {
chunks: 'all',
name: 'styles',
test: module => /(\.module)?\.css$/.test(module.type),
enforce: true,
},
},
},
},
plugins: [
...config.plugins,
new MiniCssExtractPlugin({
filename: 'static/css/[name].[hash].css',
}),
// Optional
// Silence mini-css-extract-plugin generating lots of warnings for CSS ordering.
// We use CSS modules that should not care for the order of CSS imports, so we
// should be safe to ignore these
//
// See: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/250
new FilterWarningsPlugin({
exclude: /mini-css-extract-plugin[^]*Conflicting order between:/,
}),
],
}),
themeConfig: {
logo: {
src: '/public/images/logo.png',
},
},
};