-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
91 lines (84 loc) · 2.27 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
//inline-source-map has TO BE DELETED FOR YARN BUILD< DONT KNOW WHY
const path = require("path");
const webpack = require("webpack");
const HTMLWebpackPlugin = require("html-webpack-plugin");
const dev = process.env.NODE_ENV !== "production" && process.argv.indexOf("-p") === -1;
const HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
template: path.join(__dirname, "/src/index.html"),
filename: "index.html",
inject: "body"
});
const DefinePluginConfig = new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production")
});
const UglifyJsPluginConfig = new webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: {
screw_ie8: true
},
compress: {
screw_ie8: true
},
comments: false
});
module.exports = {
devServer: {
host: "localhost",
port: "3000",
hot: true,
headers: {
"Access-Control-Allow-Origin": "*"
},
publicPath: "/",
historyApiFallback: true,
proxy: {
"/": "http://localhost:3001"
}
},
entry: ["react-hot-loader/patch", "script-loader!jquery/dist/jquery.min.js", "script-loader!foundation-sites/dist/js/foundation.min.js", path.join(__dirname, "/src/index.jsx")],
externals: {
jquery: "jQuery"
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ["babel-loader"]
},
{
test: /\.scss$/,
loader: "style-loader!css-loader!sass-loader"
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(jpe?g|png|gif|svg|ttf)$/i,
loader: "url-loader",
options: {
limit: 10000
}
},
{ test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?name=fonts/[name].[ext]' }
]
},
resolve: {
extensions: [".js", ".jsx"]
},
output: {
filename: "index.js",
path: path.join(__dirname, "/build")
},
plugins: dev ? [HTMLWebpackPluginConfig, new webpack.HotModuleReplacementPlugin(), new webpack.NamedModulesPlugin()] : [HTMLWebpackPluginConfig, DefinePluginConfig, UglifyJsPluginConfig]
//THIS HAD TO BE DELETED FOR YARN BUILD< DONT KNOW WHY
// devtool: "inline-source-map"
};