Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (55 loc) · 1.87 KB
/
Copy pathwebpack.config.js
File metadata and controls
68 lines (55 loc) · 1.87 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
//require nodejs path
const path = require('path');
//require html-webpack-plugin package #https://github.com/jantimon/html-webpack-plugin
const HTMLWebpackPlugin = require('html-webpack-plugin');
//require extract-text-webpack-plugin #https://github.com/webpack-contrib/extract-text-webpack-plugin
const ExtractTextPlugin = require('extract-text-webpack-plugin');
//export our webpack config
module.exports = {
//entry to all our js files
entry: './src/js/app.js',
//where we output our bundled js file
output: {
path: path.resolve(__dirname,'dist'),
filename: "js/app.bundle.js"
},
module: {
rules:[
//handle js compilation, we babel-loader with es2015 presets
{test: /\.js$/, use:[
{
loader: "babel-loader",
options: {
presets: ['es2015']
}
}
]},
//handle sass and use ExtractTextWebpackPlugin to extract the css
{test: /\.scss$/, use: ExtractTextPlugin.extract({
//if loader doesn't work add styles to head of the html doc
fallback: "style-loader",
//compile our sass into css
use: ['css-loader','sass-loader']
})}
]
},
plugins: [
//use html-webpack-plugin to handle out html including injecting bundled stylesheet and js
new HTMLWebpackPlugin({
template: "./src/app.html",
}),
new ExtractTextPlugin({
filename: 'css/app.bundle.css',
disable: false,
allChunks: true
})
],
//dev server configuration
devServer: {
publicPath: '/',
contentBase: path.join(__dirname, 'dist'),
compress: true,
stats: "errors-only",
open: true
}
};