This repository has been archived by the owner on Mar 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
90 lines (85 loc) · 2.68 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
/*global require: false, module: false, __dirname: false */
'use strict';
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var path = require('path');
var mdih = require('./loaders/markdown-id-headers');
var databaseKey = require('./databaseKey');
var keyParam = databaseKey.map(function (k) { return "key[]=" + k; }).join("&");
var fs = require('fs');
var analytics = '';
try {
analytics = fs.readFileSync(path.join(__dirname, '../analytics.html'));
} catch (ex) {
if (ex.code !== 'ENOENT') {
throw ex;
}
}
var port = process.env.BRCAPORT || 8080;
module.exports = {
historyApiFallback: true,
entry: "./js/index",
output: {
path: "build",
publicPath: "/",
filename: "[name].js"
},
devServer: {
port: port
},
module: {
loaders: [
// The next three are required for muts-needle-plot.
{ test: /d3-svg-legend/, loader: "imports?d3=d3" },
{ test: /muts-needle-plot/, loader: "imports?_=underscore" },
// The d3-tip AMD loader does not populate d3.tip, which is expected
// by muts-needle-plot. So, we disable it here. The CommonJS loader
// will populate d3.tip.
{ test: /d3-tip/, loader: "imports?define=>false" },
{ test: /rx-dom/, loader: "imports?define=>false" },
{ test: /\.css$/, loader: "style!css" },
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?optional=es7.objectRestSpread,optional=runtime,cacheDirectory=true'},
{
test: /\.(jpe?g|png|gif|svg|eot|woff2?|ttf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i,
loaders: ['url?limit=10000'],
exclude: [path.resolve(__dirname, "js/img/favicon")]
},
{ test: /\.md/, loader: 'html!markdown-it' },
// This is a custom loader for the database tsv file that emits a compact
// json file (no repeated property names), and does a simple sanity check,
// ensuring that the primary key is, in fact, unique.
{ test: /enigma-database.tsv$/, loader: "url?limit=10000&name=[hash].json!dsv?" + keyParam}
]
},
plugins: [
new HtmlWebpackPlugin({
title: "Template Project",
filename: "index.html",
template: "page.template",
analytics: analytics
}),
new webpack.OldWatchingPlugin()
],
resolve: {
alias: {
rx$: 'rx/dist/rx',
'rx.binding$': 'rx/dist/rx.binding',
'rx.async$': 'rx/dist/rx.async',
'rx.coincidence$': 'rx/dist/rx.coincidence',
// The npm version of d3-tip is broken. We over-ride the transitive
// dependency here, with the version we've installed.
'd3-tip$': require.resolve('d3-tip')
},
extensions: ['', '.js', '.json', '.coffee'],
root: __dirname + "/js"
},
resolveLoader: {
alias: {
'copy': 'file-loader?name=[path][name].[ext]&context=./js'
}
},
'markdown-it': {
html: true,
use: [mdih]
}
};