-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.dev.js
90 lines (89 loc) · 2.2 KB
/
webpack.dev.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
const path = require('path');
const WebpackAutoInject = require('webpack-auto-inject-version');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HandlebarsPlugin = require("handlebars-webpack-plugin");
const Entities = require('html-entities').AllHtmlEntities;
const entities = new Entities();
module.exports = {
entry: './src/docs.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'docs')
},
module: {
rules: [
{
test: /\.js$/,
exclude: [path.resolve('node_modules')],
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.scss$/,
exclude: [path.resolve('node_modules')],
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader", "postcss-loader", "sass-loader"]
})
},
{
test: require.resolve('jquery'),
use: [
{
loader: 'expose-loader',
options: '$'
}
]
},
{
test: require.resolve('fuse.js'),
use: [
{
loader: 'expose-loader',
options: 'Fuse'
}
]
}
]
},
devServer: {
contentBase: path.join(__dirname, "docs"),
//compress: true,
port: 9000
},
plugins: [
new WebpackAutoInject({
components: {
AutoIncreaseVersion: false,
InjectAsComment: false
}
}),
new ExtractTextPlugin('bundle.css'),
new HandlebarsPlugin({
entry: path.join(process.cwd(), "src", "views", "*.hbs"),
output: path.join(process.cwd(), "docs", "[name].html"),
data: require("./src/views/data.json"),
partials: [
path.join(process.cwd(), "src", "views", "partials", "*", "*.hbs")
],
helpers: {
htmlentities: function(context, options) {
return entities.encode( context );
},
jsonoption: function(value) {
if (value == 'boolean_false') {
return 'false';
}
if (value == 'boolean_true') {
return 'true';
}
return value;
}
}
})
]
};