-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
105 lines (104 loc) · 2.41 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
102
103
104
105
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const {
ProvidePlugin,
HashedModuleIdsPlugin,
NamedChunksPlugin,
} = require('webpack');
const { description } = require('./package.json');
require('./loaders/slide-loader');
module.exports = (env = {}, options) => {
const defaultMode = 'development';
const mode = options.mode || defaultMode;
const isDev = mode === defaultMode;
const template = 'index.html';
return {
entry: './index.js',
output: {
filename: isDev ? '[name].js' : '[name].[contenthash].js',
},
mode,
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
},
},
{
test: /\.scss$/,
use: [
isDev ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
],
},
{
test: /index\.html$/,
use: [
{
loader: 'slide-loader',
options: {
force: true,
isDev,
template,
},
},
],
},
],
},
devServer: {
contentBase: './public',
compress: true,
port: env.PORT || 3000,
},
optimization: {
runtimeChunk: {
name: entrypoint => `runtime~${entrypoint.name}`,
},
splitChunks: {
chunks: 'all',
name: true,
},
},
resolve: {
alias: {
reveal: 'reveal.js',
},
},
resolveLoader: {
modules: ['node_modules', './loaders'],
},
plugins: [
new HashedModuleIdsPlugin(),
new NamedChunksPlugin(),
new ProvidePlugin({
Reveal: 'expose-loader?Reveal!reveal/js/reveal',
}),
new MiniCssExtractPlugin({
filename: isDev ? '[name].css' : '[name].[contenthash].css',
}),
new HtmlWebpackPlugin({
title: description,
template,
}),
],
watchOptions: {
ignored: /slides\/\d\/.*\.html/,
},
};
};