This repository has been archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·100 lines (95 loc) · 2.9 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
"use strict";
const webpack = require('webpack');
const path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var autoprefixer = require('autoprefixer');
require("babel-polyfill");
// const Dotenv = require('dotenv-webpack');
require('dotenv').config({
path: path.join(__dirname, 'src', 'config', `.env.development`),
// path: './config/.env.${process.env.NODE_ENV}',
silent: true
});
module.exports = {
devtool: 'source-map',
entry: ['babel-polyfill',path.join(__dirname, 'src', 'client', 'entryPoint', 'app-client.js')],
output: {
path: path.join(__dirname, 'src', 'static'),
publicPath: 'http://localhost:3333/',
filename: 'bundle.js'
},
devServer: {
hot: true,
inline: true,
progress: true,
stats: 'errors-only',
port: 3333,
colors: true,
contentBase: "src/",
historyApiFallback: {
index: '/static/index.html'
}
},
node: {
fs: 'empty',
net: 'empty',
tls: 'empty',
console: true
},
module: {
loaders: [{
test: path.join(__dirname, 'src'),
loader: ['babel-loader'],
exclude: /node_modules/,
query: {
cacheDirectory: 'babel_cache',
presets: ['react', 'es2015', 'react-hmre', 'stage-2']
}
}, {
test: /\.less/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!less')
},
{
test: /\.(png|jpg|jpeg|eot|ttf|gif|svg|woff|woff2)$/,
loader: "url?limit=10000"
},
// the url-loader uses DataUrls.
// the file-loader emits files.
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },
{
test: /\.json$/,
loaders: [
'json-loader',
],
}
]
},
resolve: {
root: path.resolve(__dirname),
extensions: ['', '.js', '.jsx', '.json']
},
plugins: [
// new Dotenv({
// path: path.join(__dirname, 'config', '.env'), // if not simply .env
// safe: false // lets load the .env.example file as well
// }),
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }),
new ExtractTextPlugin('style.css'),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
process: {
env: {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
AUTH_AUDIENCE: JSON.stringify(process.env.AUTH_AUDIENCE),
AUTH_CLIENT_ID: JSON.stringify(process.env.AUTH_CLIENT_ID),
SERVER_HOST: JSON.stringify(process.env.SERVER_HOST),
SERVER_PORT: JSON.stringify(process.env.SERVER_PORT)
}
}
})
],
postcss: function () {
return [autoprefixer];
}
};