-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
94 lines (93 loc) · 2.5 KB
/
webpack.config.js
File metadata and controls
94 lines (93 loc) · 2.5 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
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
context: path.resolve(__dirname, 'src'),
entry: { app: path.resolve(__dirname, 'src/index.js') },
output: {
filename: '[name].[hash].js',
path: path.resolve(__dirname, 'dist'),
publicPath: path.resolve(__dirname, '/')
},
resolve: {
alias: {
root: path.resolve(__dirname, ''),
utils: path.resolve(__dirname, 'src/utils'),
constants: path.resolve(__dirname, 'src/constants'),
components: path.resolve(__dirname, 'src/components'),
scss: path.resolve(__dirname, 'src/styles')
}
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
include: path.resolve(__dirname, 'src'),
exclude: /node_modules/,
options: {
emitError: false,
emitWarning: true,
configFile: '.eslintrc.js'
}
},
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
'stage-2',
[
'env',
{
targets: { browsers: ['last 2 versions', 'safari >= 7', 'IE >= 9'] },
modules: false
}
]
],
plugins: [
'transform-object-rest-spread',
'transform-class-properties'
]
}
}
},
{
test: /\.scss$/,
include: path.resolve(__dirname, 'src/styles'),
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: { minimize: true }
},
{ loader: 'postcss-loader' },
{ loader: 'sass-loader' }
]
})
}
]
},
devtool: 'source-map',
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
port: 1212
},
plugins: [
new ExtractTextPlugin('styles.[hash].css'),
new HtmlWebpackPlugin({
title: 'Snake!',
inject: true,
minify: { collapseWhitespace: true },
favicon: path.resolve(__dirname, 'src/favicon.ico'),
template: path.resolve(__dirname, 'src/index.ejs'),
description: 'Vanilla JS game of snake'
})
]
}