generated from dchyun/starter-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
71 lines (66 loc) · 2.87 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
const path = require('path');
const HandlebarsWebpackPlugin = require("handlebars-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require('webpack');
module.exports = {
mode: 'production',
entry: {
bundle: './src/app.js',
home: './src/scripts/home.js',
'project-detail': './src/scripts/project-detail.js',
evolution: './src/scripts/evolution.js',
migration: './src/scripts/migration.js',
workshop: './src/scripts/workshop.js',
about: './src/scripts/about.js',
'project-card-animation': './src/scripts/project-card-animation.js',
'project-card-evolution': './src/scripts/project-card-evolution.js',
'project-card-migration': './src/scripts/project-card-migration.js',
'project-card-workshop': './src/scripts/project-card-workshop.js',
'tony-hyun': './src/scripts/tony-hyun.js'
},
output: {
path: path.resolve(__dirname, './dist'),
assetModuleFilename: 'assets/[name][ext][query]'
},
module: {
rules: [
{
test: /\.(png|svg|jpg|jpeg|gif|pdf|mp4)$/i,
type: 'asset/resource',
},
]
},
plugins: [
new HandlebarsWebpackPlugin({
// path to hbs entry file(s). Also supports nested directories if write path.join(process.cwd(), "app", "src", "**", "*.hbs"),
entry: path.join(__dirname, "src", "app", "*.hbs"),
// output path and filename(s). This should lie within the webpacks output-folder
// if ommited, the input filepath stripped of its extension will be used
output: path.join(__dirname, "dist", "[name].html"),
// you can also add a [path] variable, which will emit the files with their relative path, like
// output: path.join(process.cwd(), "build", [path], "[name].html"),
// data passed to main hbs template: `main-template(data)`
// data: require(".src/app/data/project.json"),
// or add it as filepath to rebuild data on change using webpack-dev-server
data: path.join(__dirname, "src/app/data/project.json"),
// globbed path to partials, where folder/filename is unique
partials: [
path.join(__dirname, "src", "app", "partials", "*.hbs")
],
// register custom helpers. May be either a function or a glob-pattern
// helpers: {
// nameOfHbsHelper: Function.prototype,
// projectHelpers: path.join(process.cwd(), "app", "helpers", "*.helper.js")
// },
// hooks
// getTargetFilepath: function (filepath, outputTemplate) {},
// getPartialId: function (filePath) {}
onBeforeSetup: function (Handlebars) {},
onBeforeAddPartials: function (Handlebars, partialsMap) {},
onBeforeCompile: function (Handlebars, templateContent) {},
onBeforeRender: function (Handlebars, data, filename) {},
onBeforeSave: function (Handlebars, resultHtml, filename) {},
onDone: function (Handlebars, filename) {}
})
]
};