-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.dev.config.js
123 lines (116 loc) · 3.21 KB
/
webpack.dev.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
var hook = require('css-modules-require-hook');
var hljs = require('highlight.js');
var Webpack_isomorphic_tools_plugin = require('webpack-isomorphic-tools/plugin');
var webpack_isomorphic_tools_plugin =
// webpack-isomorphic-tools settings reside in a separate .js file
// (because they will be used in the web server code too).
new Webpack_isomorphic_tools_plugin(require('./webpack-isomorphic-tools-configuration'))
// also enter development mode since it's a development webpack configuration
// (see below for explanation)
.development()
module.exports = function checkMode(app){
hook({
generateScopedName: '[name]__[local]___[hash:base64:5]',
});
require('asset-require-hook')({
extensions: ['md']
})
if(app){
var path = require('path');
var webpack = require('webpack');
var config = {
debug: true,
context: __dirname,
devtool: 'eval',
entry: [
'babel-polyfill',
'webpack-hot-middleware/client',
'./client/client'
],
resolve: {
root: [ __dirname ],
extensions: ["", ".js", ".jsx"]
},
output: {
path: path.join(__dirname, '/public/build'),
publicPath: '/build/',
filename: 'bundle.js'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.IgnorePlugin(new RegExp("asyncBeApi")),
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./manifest.json'),
}),
webpack_isomorphic_tools_plugin
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
include: __dirname,
query: {
plugins: [
[
'react-transform',
{
'transforms': [{
'transform': 'react-transform-hmr',
'imports': ['react'],
'locals': ['module']
}]
}
]
]
}
},
{
test: /\.css$/,
loader: "style-loader!css-loader?modules&localIdentName=[path][name]__[local]",
include: __dirname
},
{ test: /\.md$/, loader: "html!markdownattrs?config=markdownattrsLoaderCustomConfig" },
{
test: webpack_isomorphic_tools_plugin.regular_expression('images'),
loader: 'file', // any image below or equal to 10K will be converted to inline base64 instead
},
/*{
test: /\.(png|svg|ttf|woff)$/,
loader: 'file?emitFile=false'
},*/
{
test: /\.json$/,
loader: 'json'
},
]
},
markdownattrsLoaderCustomConfig: {
html: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
}
}
};
var compiler = webpack(config);
app.use(require("webpack-dev-middleware")(compiler, {
noInfo: true,
publicPath: config.output.publicPath,
stats: {
colors: true
}
}));
app.use(require("webpack-hot-middleware")(compiler));
}
};