-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
101 lines (94 loc) · 2.27 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin')
// change these variables to fit your project
const jsPath= './assets/scripts';
const cssPath = './';
const outputPath = 'dist';
const extractBundle = new ExtractTextPlugin('bundle.css');
const entryPoints = {
// 'app' is the output name, people commonly use 'bundle'
// you can have more than 1 entry point
'app': jsPath + '/main.js',
};
const PATHS = {
assets: {
fonts: path.join(__dirname, 'assets', 'fonts'),
icons: path.join(__dirname, 'assets', 'icons'),
},
modules: path.join(__dirname, 'modules'),
dist: path.join(__dirname, 'dist'),
};
module.exports = {
devtool: 'source-map',
entry: entryPoints,
output: {
path: PATHS.dist,
// filename: '[name].js',
filename: 'bundle.js',
},
plugins: [
extractBundle
// new MiniCssExtractPlugin({
// filename: '[name].css',
// }),
// Uncomment this if you want to use CSS Live reload
/*
new BrowserSyncPlugin({
proxy: localDomain,
files: [ outputPath + '/*.css' ],
injectCss: true,
}, { reload: false, }),
*/
],
module: {
rules: [
{
test: /\.s?[c]ss$/i,
use: extractBundle.extract({
fallback: 'style-loader',
use: [ 'css-loader']
})
},
{
test: /main\.css$/,
use: extractBundle.extract({
fallback: 'style-loader',
use: [ 'css-loader']
})
},
{
test: /\.(jpg|jpeg|png|gif|woff|woff2|eot|ttf)$/i,
use: 'url-loader?limit=1024',
},
{
test: /\.pug$/,
include: [
PATHS.modules
],
use: 'pug-loader'
},
{
test: /\.svg$/,
include: [
PATHS.assets.icons
],
use: 'svg-sprite-loader?name=icon-[name]'
},
{
test: /\.svg$/,
exclude: [
PATHS.assets.fonts,
PATHS.assets.icons,
],
use: 'svg-url-loader'
},
]
},
externals: {
// require("jquery") is external and available
// on the global var jQuery
"jquery": "jQuery"
}
};