-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
84 lines (82 loc) · 1.99 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
const path = require('path');
const pkg = require('./package.json');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const paths = {
src: path.join(__dirname, './src'),
build: path.join(__dirname, './dist'),
assets: path.resolve(__dirname, './assets'),
nodeModules: path.resolve(__dirname, './node_modules')
};
module.exports = (env) => ({
entry: {
main: paths.src + '/index.js',
portfolio: paths.src + '/portfolio/index.js',
},
output: {
path: paths.build,
filename: '[name].[hash].js'
},
mode: 'development',
target: 'web',
devtool: 'source-map',
devServer: {
hot: true,
static: {
directory: paths.assets,
publicPath: '/assets'
},
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: paths.nodeModules,
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: { sourceMap: true, importLoaders: 1, modules: false },
},
{ loader: 'postcss-loader', options: { sourceMap: true } },
],
},
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'La Jarre à Son',
favicon: paths.assets + '/favicon.png',
template: paths.src + '/index.html',
filename: 'index.html',
chunks: ['main'],
}),
new HtmlWebpackPlugin({
title: 'La Jarre à Son - Portfolio',
favicon: paths.assets + '/favicon.png',
template: paths.src + '/portfolio/index.html',
filename: 'portfolio.html',
chunks: ['portfolio'],
}),
new webpack.DefinePlugin({
'PRODUCTION': JSON.stringify(env.production),
}),
new CopyWebpackPlugin({
patterns: [
{
from: paths.assets,
to: paths.build + '/assets',
}
]
}),
],
watchOptions: {
aggregateTimeout: 200,
poll: 1000,
},
});