-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
101 lines (89 loc) · 2.19 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
const fs = require("fs")
const path = require("path")
const webpack = require("webpack")
function isDirectory(dir) {
return fs.lstatSync(dir).isDirectory()
}
const SubjectsDir = path.join(__dirname, "subjects")
const SubjectDirs = fs.readdirSync(SubjectsDir).filter(function(dir) {
return isDirectory(path.join(SubjectsDir, dir))
})
module.exports = {
devtool: "source-map",
entry: SubjectDirs.reduce(
function(entries, dir) {
if (fs.existsSync(path.join(SubjectsDir, dir, "exercise.js")))
entries[dir + "-exercise"] = path.join(
SubjectsDir,
dir,
"exercise.js"
)
if (fs.existsSync(path.join(SubjectsDir, dir, "solution.js")))
entries[dir + "-solution"] = path.join(
SubjectsDir,
dir,
"solution.js"
)
if (fs.existsSync(path.join(SubjectsDir, dir, "lecture.js")))
entries[dir + "-lecture"] = path.join(
SubjectsDir,
dir,
"lecture.js"
)
return entries
},
{
shared: ["react", "react-dom"]
}
),
output: {
path: "__build__",
filename: "[name].js",
chunkFilename: "[id].chunk.js",
publicPath: "/__build__/"
},
resolve: {
extensions: ["", ".js", ".css"]
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
{
test: /\.js$/,
exclude: /node_modules|mocha-browser\.js/,
loader: "babel"
},
{
test: /\.woff(2)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
},
{ test: /\.(ttf|eot|svg|png|jpg)$/, loader: "file" },
{ test: require.resolve("jquery"), loader: "expose?jQuery" }
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ name: "shared" })
],
devServer: {
quiet: false,
noInfo: false,
historyApiFallback: {
rewrites: [
{
from: /ReduxDataFlow\/exercise.html/,
to: "ReduxDataFlow/exercise.html"
}
]
},
stats: {
// Config for minimal console.log mess.
assets: true,
colors: true,
version: true,
hash: true,
timings: true,
chunks: false,
chunkModules: false
}
}
}