-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
99 lines (93 loc) · 2.5 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const path = require('path');
// Added in output management, HtmlWebpackPlugin section.
const HtmlWebpackPlugin = require('html-webpack-plugin');
// Added to cleanup dist folder
const {
CleanWebpackPlugin,
} = require('clean-webpack-plugin');
// Used to add vendor-specific styles to Sass files, config w PostCSS-loader
const autoprefixer = require('autoprefixer');
module.exports = {
// swap to dev mode if developing
// mode: 'development',
mode: 'production',
entry: {
app: './src/index.js',
// print: './src/print.js', No second file present yet, add more here
},
devtool: 'inline-source-map',
// Below line tells webpack-dev-server to server files from /dist directory on
// localhost:8080(or port set in servr.js)
// run using webpack-dev-server --open or script in package.json $ npm run start
devServer: {
contentBase: './dist',
},
plugins: [
new HtmlWebpackPlugin({
title: 'tribe | Eat a little. Drink a little. Flirt a little. Tell your most awesome stories.',
favicon: './src/img/1599847804.ico',
}),
// Added for second plugin, the option Tells CleanWebpackPlugin that we don't
// want to remove the index.html file after the incremental build triggered by watch
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false,
}),
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
module: {
rules: [{
test: /\.s[ac]ss$/i,
use: [{
// Creates `style` nodes from JS strings
loader: 'style-loader',
},
{
// Translates CSS into CommonJS
loader: 'css-loader',
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
autoprefixer(),
],
},
},
},
{
// Compiles Sass to CSS
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: ['./node_modules'],
},
// Prefer Dart Sass
implementation: require('sass'),
// See https://github.com/webpack-contrib/sass-loader/issues/804
webpackImporter: false,
},
},
],
},
{
// File loader to include images
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader',
],
},
{
// File loader to include fonts
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader',
],
},
],
},
};