forked from huangzhipeng/amazeui-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.docs.js
118 lines (106 loc) · 2.67 KB
/
webpack.docs.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
import path from 'path';
import webpack from 'webpack';
import marked from 'marked';
import hl from 'highlight.js';
import HTMLWebpackPlugin from 'html-webpack-plugin';
const isProduction = process.env.NODE_ENV === 'production';
const codeRenderer = function(code, lang) {
lang = lang === 'js' ? 'javascript' : lang;
if (lang === 'html') {
lang = 'xml';
}
let hlCode = lang ?
hl.highlight(lang, code).value : hl.highlightAuto(code).value;
return `<div class="doc-highlight"><pre>
<code class="${lang || ''}">${hlCode}</code></pre></div>`;
};
let renderer = new marked.Renderer();
renderer.code = codeRenderer;
const entry = './docs/app.js';
const devEntry = [
'webpack/hot/dev-server',
'webpack-hot-middleware/client?reload=true',
entry,
];
const basePlugins = [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
new HTMLWebpackPlugin({
title: 'Amaze UI React',
template: 'docs/index.html',
UICDN: isProduction ? 'http://cdn.amazeui.org/amazeui/2.5.0/' : '',
assets: isProduction ? 'http://s.amazeui.org/assets/react' : '',
minify: isProduction ? {
removeComments: true,
collapseWhitespace: true
} : null,
}),
];
const envPlugins = isProduction ? [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.BannerPlugin(`Last update: ${new Date().toString()}`),
] : [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
];
export default {
debug: !isProduction,
devtool: !isProduction ? '#eval' : null,
entry: isProduction ? entry : devEntry,
output: {
path: path.join(__dirname, 'www'),
filename: `app.[hash:7]${isProduction ? '.min' : ''}.js`,
chunkFilename: '[id].chunk.js',
publicPath: '/'
},
module: {
// noParse: /babel-core/,
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [
'react-hot',
'transform/cacheable?brfs',
'babel'
],
},
{
test: /\.less$/,
loaders: [
'style',
'css?minimize',
'autoprefixer',
'less'
],
include: [
path.join(__dirname, 'docs')
]
},
{
test: /\.md$/,
loader: 'html!markdown'
},
{
test: /\.jpe?g$|\.gif$|\.png|\.ico$/,
loader: 'file?name=[path][name].[ext]&context=docs/assets'
},
]
},
plugins: basePlugins.concat(envPlugins),
// watch: !isProduction,
node: {
fs: 'empty'
},
markdownLoader: {
renderer: renderer
}
};