-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.js
143 lines (126 loc) · 4.05 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
const WebPak = require("webpack");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const fs = require("fs");
const webpages = JSON.parse(fs.readFileSync("./src/pages/pages.json", "utf8"));
const DashboardPlugin = require("webpack-dashboard/plugin");
const entryHtmlPlugins = webpages.map(function(entryName) {
return new HtmlWebpackPlugin({
filename: entryName + ".html",
template: __dirname + `/src/partials/template.html`,
inject: false,
title: entryName,
meta: [{
name: 'description',
content: 'A better default template for html-webpack-plugin.'
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1, shrink-to-fit=no'
}
],
mobile: true,
lang: 'en-US',
// devServer:'//localhost:9000',
// inlineManifestWebpackName: 'webpackManifest',
// googleAnalytics: {
// trackingId: 'UA-XXXX-XX',
// pageViewOnLoad: true
// },
});
});
module.exports = {
mode: "development",
devtool: 'inline-source-map',
entry: path.resolve(__dirname, "index.js"),
target: 'web',
devServer: {
contentBase: path.join(__dirname, "dist"),
watchContentBase: true,
compress: true,
historyApiFallback: true,
hot: true,
port: 9000,
open: true,
serveIndex: true,
// writeToDisk:true
},
module: {
rules: [{
test: /\.(s[ac]|c)ss$/i,
exclude: /node_modules/,
use: ["style-loader", "css-loader", {
loader: 'resolve-url-loader',
}, "postcss-loader", {
loader: "sass-loader",
options: {
sourceMap: true,
// implementation: require("dart-sass"),
sassOptions: {
indentWidth: 4,
includePaths: [
// path.resolve(__dirname, "/src/scss/pages/"),
// path.resolve(__dirname, "node_modules/bootstrap/scss/"),
// path.resolve(__dirname, "node_modules/bootstrap/scss/"),
// require("bourbon").includePaths,
// require("rfs").includePaths
],
outputStyle: "compressed",
}
}
}, ],
},
{
test: /\.(gif|png|jpe?g|mp4|webm)$/,
type: 'asset/resource',
generator: {
filename: 'assets/img/[name][ext]'
}
},
{
test: /\.(mp4|webm)$/,
type: 'asset/resource',
generator: {
filename: 'assets/videos/[name][ext]'
}
},
{
test: /\.(svg)$/,
type: 'asset/inline'
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
generator: {
filename: 'assets/fonts/[name][ext]'
}
},
]
},
output: {
path: path.join(__dirname, './', "dist"),
filename: "bundle.js",
clean: true,
// assetModuleFilename: 'assets/img/[name][ext]'
},
resolveLoader: {
modules: [
path.join(__dirname, 'node_modules')
]
},
resolve: {
modules: [
path.join(__dirname, 'node_modules')
],
},
plugins: [
new DashboardPlugin(),
new WebPak.HotModuleReplacementPlugin(),
new WebPak.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
_: "underscore"
}),
]
.concat(entryHtmlPlugins)
};