-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
74 lines (69 loc) · 1.52 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
'use strict'
// https://webpack.js.org/configuration/
const path = require('path')
const webpack = require('webpack')
const CleanPlugin = require('clean-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const HtmlPlugin = require('html-webpack-plugin')
const srcDir = path.resolve(__dirname, 'src')
const distDir = path.resolve(__dirname, 'dist')
const staticDir = path.resolve(__dirname, 'static')
const moduleDir = path.resolve(__dirname, 'node_modules')
module.exports = {
context: srcDir,
entry: {
bundle: './index.jsx'
},
output: {
path: distDir,
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
include: srcDir,
use: ['babel-loader']
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: true
}
}
]
},
{
test: /\.(png|jpg)$/,
use: ['url-loader']
}
]
},
plugins: [
new CleanPlugin([distDir]),
new CopyPlugin([
{ from: staticDir },
{ from: `${moduleDir}/spectre.css/dist`, ignore: '*.min.*' }
]),
new HtmlPlugin({
title: 'React Pets',
filename: 'index.html',
inject: true,
template: `${srcDir}/index.html.ejs`
})
],
resolve: {
extensions: ['.js', '.jsx']
},
devtool: 'source-map',
devServer: {
contentBase: staticDir,
overlay: true,
port: 3000
}
}