forked from robyth/amazeui-touch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.docs.babel.js
127 lines (116 loc) · 3.07 KB
/
webpack.docs.babel.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
'use strict';
import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import autoprefixer from 'autoprefixer';
import markedOptions from './docs/utils/markeqOptions';
import pkg from './package.json';
const prod = process.env.NODE_ENV === 'production';
const hotEntry = [
'webpack/hot/dev-server',
'webpack-hot-middleware/client?reload=true',
];
const docsEntry = './docs/js/app.js';
const ksEntry = './kitchen-sink/entry.js';
let minify = prod ? {
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
} : false;
let plugins = [
new HtmlWebpackPlugin({
template: 'docs/index.html',
prod,
chunks: ['docs'],
minify,
}),
new HtmlWebpackPlugin({
filename: 'kitchen-sink/index.html',
template: 'kitchen-sink/index.html',
chunks: ['ks'],
minify,
}),
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
SERVER_RENDING: false,
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
},
}),
];
plugins = prod ? plugins.concat([
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new ExtractTextPlugin('[name].[hash:5].min.css'),
new webpack.BannerPlugin(`build: ${new Date().toString()}`),
]) : plugins.concat([
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
]);
export default {
devtool: prod ? null : 'eval',
entry: {
docs: prod ? docsEntry : [].concat(hotEntry).concat(docsEntry),
ks: prod ? ksEntry : [].concat(hotEntry).concat(ksEntry),
},
output: {
filename: `[name].[hash:5]${prod ? '.min' : ''}.js`,
path: `${__dirname}/www`,
// publicPath: '',
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: [
'transform/cacheable?brfs',
'babel',
]
},
{
test: /\.md$/,
loader: 'html!markdown'
},
{
test: /\.scss$/,
loader: prod ? ExtractTextPlugin.extract(
'style',
'css?minimize!postcss!sass',
) : 'style!css?sourceMap!postcss!sass?sourceMap',
},
/*{
test: /\.(ttf|svg|woff)$/,
loader: 'file?name=[path][name].[ext]&context=src'
},*/
// @see https://shellmonger.com/2016/01/22/working-with-fonts-with-webpack/
{
test: /\.svg$/,
loader: 'url?mimetype=image/svg+xml&name=[name].[ext]'
},
{
test: /\.woff$/,
loader: 'url?mimetype=application/font-woff&name=[name].[ext]'
},
{
test: /\.woff2$/,
loader: 'url?mimetype=application/font-woff2&name=[name].[ext]'
},
{
test: /\.[ot]tf$/,
loader: 'url?mimetype=application/octet-stream&name=[name].[ext]'
},
]
},
plugins: plugins,
node: {
fs: 'empty'
},
markdownLoader: markedOptions,
postcss: [autoprefixer({browsers: ['> 1%', 'last 2 versions', 'ie 10']})],
};