This repository has been archived by the owner on Feb 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.babel.js
115 lines (99 loc) · 2.5 KB
/
webpack.config.babel.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
111
112
113
114
115
import path from "path";
import webpack from "webpack";
import HtmlWebpackPlugin from "html-webpack-plugin";
import UglifyJsPlugin from "uglifyjs-webpack-plugin";
const PRODUCTION = process.env.NODE_ENV === "production";
let PATHS = {};
PATHS.src = path.resolve(__dirname, "src");
PATHS.dist = path.resolve(__dirname, "dist");
PATHS.entry = path.resolve(PATHS.src, "index");
const PORT = 8000;
const DEV_SOURCES = ["webpack/hot/dev-server", `webpack-dev-server/client?http://localhost:${PORT}`];
const generateEntrySources = (sources) => !PRODUCTION ? DEV_SOURCES.concat(sources) : sources;
module.exports = {
entry: [
"babel-polyfill",
PATHS.entry,
],
output: {
path: PATHS.dist,
chunkFilename: PRODUCTION ? "[id]-[chunkhash].chunk.js" : "[id].chunk.js",
filename: PRODUCTION ? "[name]-[hash].bundle.js" : "[name].bundle.js",
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [ PATHS.src ],
exclude: [ path.resolve(__dirname, "node_modules") ],
use: [ "babel-loader" ],
},
{
test: /\.scss$/,
include: [
PATHS.src,
path.resolve(__dirname, "node_modules/font-awesome"),
],
// exclude: [ path.resolve(__dirname, "node_modules") ],
use: [
"style-loader",
"css-loader",
"sass-loader",
],
},
{
test: /\.css$/,
include: [ PATHS.src ],
exclude: [ path.resolve(__dirname, "node_modules") ],
use: [
"style-loader",
"css-loader",
],
},
{
test: [
/\.ttf$/,
/\.eot$/,
/\.woff2?/,
/\.svg$/,
/\.otf$/,
],
use: [
{
loader: "url-loader",
options: {
name: "fonts/[name].[ext]",
},
},
],
},
],
},
resolve: {
modules: [
"node_modules",
path.resolve(__dirname, "src"),
],
extensions: [ ".js", ".jsx", ".css", ".json" ],
},
devServer: {
hot: true,
port: PORT,
},
devtool: "source-map",
target: "web",
plugins: [
new HtmlWebpackPlugin({
title: "Clean Architecture Demo",
template: path.resolve(PATHS.src, "template.html"),
}),
new webpack.HotModuleReplacementPlugin(),
// new UglifyJsPlugin({
// compress: false,
// beautify: false,
// extractCommends: false,
// // output: { comments: false },
// sourceMap: true,
// }),
],
};