-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
110 lines (101 loc) · 2.09 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
100
101
102
103
104
105
106
107
108
109
110
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const imagesRegex = /\.(bmp|gif|jpg|jpeg|png|svg)$/;
const fontsRegex = /\.(eot|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/;
// Presets for the babel loader
const babelPresets = [
[
'env',
{
targets: {
browsers: ['last 2 versions']
}
}
],
'react'
];
// JS / JSX Rules
const jsRules = {
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: babelPresets,
// Don't read from .babelrc
babelrc: false
}
};
// GraphQL / GQL Rules
const gqlRules = {
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
use: 'graphql-tag/loader'
};
// SCSS Rules
const scssRules = {
test: /\.(scss|css)/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
minimize: true
}
},
{ loader: 'sass-loader' }
]
})
};
// Images Rules
const imagesRules = {
test: imagesRegex,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
};
// Fonts Rules
const fontsRules = {
test: fontsRegex,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
};
const config = {
entry: path.join(__dirname, 'src', 'app.js'),
output: {
path: path.resolve(__dirname, 'public'),
filename: 'app.js'
},
resolve: {
extensions: ['.js', '.jsx', '.gql', '.scss', '.pcss'],
modules: [path.resolve(__dirname, 'src'), 'node_modules']
},
devServer: {
contentBase: path.join(__dirname, 'public'),
headers: {
'Access-Control-Allow-Origin': '*'
},
stats: 'errors-only',
open: true
},
plugins: [
new ExtractTextPlugin('style.css'),
new HtmlWebpackPlugin({
inject: 'head',
title: 'Meetup Topics',
template: path.join(__dirname, 'static', 'index.html')
})
],
module: {
rules: [jsRules, gqlRules, scssRules, imagesRules, fontsRules]
}
};
module.exports = config;