forked from udacity/mws-restaurant-stage-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
63 lines (62 loc) · 1.75 KB
/
webpack.common.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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: {
'js/main': './src/js/main.js',
'js/restaurant': './src/js/restaurant_info.js',
sw: './src/sw.js',
styles: './src/css/styles.css'
},
output: {
path: path.resolve(__dirname, 'dist'),
chunkFilename: '[name].js',
filename: '[name].js'
},
plugins: [
new CopyWebpackPlugin([{ from: 'src/offline.html', to: 'offline.html' }]),
new CopyWebpackPlugin([{ from: 'src/favicon.ico', to: 'favicon.ico' }]),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
excludeAssets: [/styles.*\.js/],
chunks: ['styles', 'js/main']
}),
new HtmlWebpackPlugin({
filename: 'restaurant.html',
template: 'src/restaurant.html',
excludeAssets: [/styles.*\.js/],
chunks: ['styles', 'js/restaurant']
}),
new HtmlWebpackExcludeAssetsPlugin(),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[name].css'
})
],
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
fallback: 'responsive-loader',
sizes: [840, 720, 600, 480, 360],
quality: 70,
name: 'img/[name]-[width]px.[ext]'
}
}
]
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
}
};