forked from aneagoie/keiko-corp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
87 lines (86 loc) · 2.21 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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MergeIntoSingleFilePlugin = require('webpack-merge-and-include-globally')
const uglifyJS = require('uglify-js')
const CleanCSS = require('clean-css')
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')
module.exports = {
entry: './src/js/main.js',
module: {
rules: [
{
test: /\.(png|jp(e*)g|svg|gif)$/i,
type: 'asset',
use: [
{
loader: 'url-loader',
},
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
],
},
plugins: [
new HtmlWebpackPlugin({
hash: true,
title: 'Webpack demo',
header: '<h1>Webpack demo</h1>',
metaDesc: 'This is a demo of webpack',
template: './src/index.html',
filename: 'index.html',
inject: 'body',
}),
new MergeIntoSingleFilePlugin({
files: {
'vendor.js': [
// './src/js/main.js',
'./src/js/lib/jquery.js',
'./src/js/lib/bootstrap.min.js',
'./src/js/lib/ajaxchimp.js',
'./src/js/lib/nicescroll.js',
'./src/js/lib/owl.carousel.min.js',
'./src/js/lib/parallax.js',
'./src/js/lib/scrollTo.js',
'./src/js/lib/wow.js',
],
'style.css': [
'./src/css/main.css',
'./src/css/animate.css',
'./src/css/bootstrap.css',
'./src/css/owl.carousel.css',
'./src/css/owl.theme.css',
'./src/css/owl.transitions.css',
'./src/css/reset.css',
],
},
transform: {
'vendor.js': (code) => uglifyJS.minify(code).code,
'style.css': (code) => new CleanCSS({}).minify(code).styles,
},
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'src/img'),
to: path.resolve(__dirname, 'dist/img'),
},
{
from: path.resolve(__dirname, 'src/fonts'),
to: path.resolve(__dirname, 'dist/fonts'),
},
],
}),
],
output: {
clean: true,
},
devServer: {
static: path.join(__dirname, 'dist'),
compress: true,
open: false,
port: 3000,
},
}