-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.dev.js
More file actions
95 lines (88 loc) · 2.34 KB
/
webpack.dev.js
File metadata and controls
95 lines (88 loc) · 2.34 KB
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
// Webpack development configuration
/**
* This utility allows webpack to 'merge' configurations together.
* To keep code DRY we can seperate common configuration and merge that into development or production.
*/
const merge = require('webpack-merge');
/**
* My common webpack congiuration tasks
*/
const common = require('./webpack.common.js');
/**
* This plugin will search for CSS assets during the Webpack build and will optimize \ minimize the CSS
*/
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
/**
* This plugin will minify the JS
*/
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
/**
* Copies individual files or entire directories to the build directory
*/
const CopyWebpackPlugin = require('copy-webpack-plugin');
/**
* Plugin that simplifies creation of HTML files to serve your bundles
*/
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = merge(common, {
mode: 'development',
devtool: 'source-map',
devServer: {
contentBase: './dist',
port: 8080
},
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true
}),
new OptimizeCSSAssetsPlugin({})
]
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader', // Injects CSS into the DOM via a <style> tag
{
loader: 'css-loader', // The css-loader interprets @import and url() like import/require() and will resolve them.
options: {
sourceMap: true, // Includes source maps to our CSS files
importLoaders: 1 // Number of loaders to use before this loader (i.e. postcss first)
}
},
'postcss-loader' // Uses our postcss.config file to add vendor prefixes to our CSS
]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
]
}
]
},
plugins: [
new CopyWebpackPlugin([
'src/sw.js',
{
from: 'src/icons',
to: './icons',
},
'src/manifest.json',
'src/browserconfig.xml'
]),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
chunks: ['index']
}),
]
});