-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
87 lines (80 loc) · 2.36 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
"use strict";
let glob = require('glob');
let StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
// Setup automatic route configuration.
let routes = [];
let routesMap = {};
const files = glob.sync('./content/**/*.content');
files.forEach((element, index, array) => {
let route = array[index].replace('./content/', '');
if (route.includes('index')) {
routes.push('/' + route.replace(/(\.pug|\.md)\.content/, '').replace('index', ''));
routesMap['/' + route.replace(/(\.pug|\.md)\.content/, '').replace('index', '')] = route;
}
else {
routes.push('/' + route.replace(/(\.pug|\.md)\.content/, '.html').replace('index', ''));
routesMap['/' + route.replace(/(\.pug|\.md)\.content/, '.html').replace('index', '')] = route;
}
});
// Setup Configuraion Variables.
const configurationFiles = glob.sync('./config/**.yml');
module.exports = {
// context: process.cwd(),
entry: './index.js',
output: {
filename: "index.js",
path: '_site',
libraryTarget: 'umd'
},
module: {
// preLoaders: [
// {
// // test: /\.js$/,
// // exclude: /node_modules/,
// // loader: 'jshint-loader'
//
// }
// ],
loaders: [
{
test: /\.js$/,
exclude: /node_modules|~|_./,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
include: /\.yml$|\.yaml$/,
exclude: /node_modules|\/~\//,
loaders: ['json-loader', 'yaml-loader']
},
{
include: /\.jade$|\.pug$/,
exclude: /node_modules|~/,
loader: 'jade-loader'
},
{
test: /\.pug\.content$/,
exclude: /node_modules|~/,
loaders: ['raw', './src/loaders/pug-head-loader', './src/loaders/template-wrapper-loader', 'yaml-head-loader']
},
{
test: /\.md\.content$/,
exclude: /node_modules|~/,
loaders: ['raw', './src/loaders/markdown-head-loader', 'yaml-head-loader']
}
]
},
resolve: {
extensions: ['', '.js', '.es6', 'pug', 'jade', 'pug.content', 'md.content'],
modulesDirectories: ["web_modules", "bower_components", "node_modules"]
},
target: 'node',
debug: true,
cache: false,
devtool: 'eval',
plugins: [
new StaticSiteGeneratorPlugin('index.js', routes, { "routesMap": routesMap, "configurationFiles": configurationFiles})
]
}