-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
98 lines (96 loc) · 2.39 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
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const isProd = process.argv.indexOf('-p') !== -1;
const config = {
entry: {
app: './src/scripts/main.js',
},
output: {
filename: isProd ? '[name].[chunkhash:8].js' : '[name].js',
path: path.join(__dirname, 'build'),
publicPath: '/',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
include: __dirname + '/src/scripts',
loader: 'eslint-loader',
exclude: /node_modules/,
options: {
configFile: './.eslintrc',
},
},
{
test: /\.js$/,
include: __dirname + '/src/scripts',
loader: 'babel-loader',
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: true,
importLoaders: 1,
localIdentName: '[name]__[local]'
}
},
{
loader: 'postcss-loader',
},
],
}),
},
{
test: /\.html/,
loader: 'html-loader',
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader',
options: {
name: isProd ? 'fonts/[name].[hash:8].[ext]' : 'fonts/[name].[ext]',
},
},
{
test: /\.(jpe?g|png|gif)$/i,
loader: 'file-loader',
options: {
hash: 'sha512',
digest: 'hex',
name: isProd ? 'images/[name].[hash:8].[ext]' : 'images/[name].[ext]',
},
},
],
},
plugins: [
new ExtractTextPlugin({
filename: isProd ? '[name].[contenthash:8].css' : '[name].css',
ignoreOrder: true,
}),
new HtmlWebpackPlugin({
template: 'src/index.ejs',
title: 'd-low.com - The website of Mike DiLorenzo: Hikes and Travels in Colorado, Latin America, and on the CDT',
}),
new webpack.ProvidePlugin({
Promise: 'es6-promise',
}),
],
resolve: {
extensions: ['.css', '.js'],
modules: [
path.join(__dirname, 'src'),
'node_modules',
],
},
};
module.exports = config;