This repository has been archived by the owner on Jul 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
105 lines (97 loc) · 2.46 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { DefinePlugin, optimize } = require('webpack');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
// const ImageminPlugin = require('imagemin-webpack-plugin').default;
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
const path = require('path');
const autoprefixer = require('autoprefixer');
const NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : 'development';
const THEME_DIR = 'src/';
// Plugins
const plugins = [];
plugins.push(new HtmlWebpackPlugin({
template: THEME_DIR + 'public/index.html',
inject: 'body',
filename: 'index.html',
}));
plugins.push(new HtmlWebpackPlugin({
template: THEME_DIR + 'public/humans.txt',
inject: false,
filename: 'humans.txt',
}));
plugins.push(new FaviconsWebpackPlugin({
logo: './src/public/favicon.png',
inject: true,
}));
if (NODE_ENV === 'production') {
plugins.push(new optimize.DedupePlugin());
plugins.push(new DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(NODE_ENV),
},
}));
plugins.push(new optimize.UglifyJsPlugin({
compress: {
warnings: true,
},
}));
plugins.push(new ExtractTextPlugin('texascamp.[hash].css'));
// plugins.push(new ImageminPlugin(['/.*/', './icons-*/**']));
plugins.push(new StyleExtHtmlWebpackPlugin());
}
// Loaders
const loaders = [
{
test: /\.yaml$/,
loaders: ['json', 'yaml'],
},
{
test: /\.js|.jsx$/,
exclude: /node_modules/,
loader: 'babel',
query:
{
presets:['react']
}
},
{
test: /\.png|.svg|.jpg|.gif|\.ttf|\.woff|\.eot|\.ico$/,
loaders: ['file'],
},
{
test: /\.pdf$/,
loader: 'file',
query:
{
name: '[name]-[hash].[ext]'
}
},
];
if (NODE_ENV === 'production') {
loaders.push({
test: /\.s?css$/,
loader: ExtractTextPlugin.extract('style', ['css', 'postcss', 'sass']),
});
} else {
loaders.push({
test: /\.s?css$/,
loaders: ['style', 'css', 'postcss', 'sass'],
});
}
module.exports = {
entry: "./" + THEME_DIR + 'index.jsx',
output: {
path: `${__dirname}` + '/build',
filename: 'texascamp.[hash].js',
},
module: {
noParse: [
path.resolve('node_modules/react-quill/node_modules/quill/dist/quill.js'),
path.resolve('node_modules/quill/dist/quill.js'),
],
loaders,
},
postcss: () => [autoprefixer],
plugins,
};