-
Notifications
You must be signed in to change notification settings - Fork 18
/
webpack-dev-server.config.js
145 lines (142 loc) · 3.88 KB
/
webpack-dev-server.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
const webpack = require('webpack')
const path = require('path')
const buildPath = path.resolve(__dirname, 'src/www')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const cookie = {
name: "pendo.sess",
value: process.env.PENDO_SESS
}
const header = {
Cookie: cookie.name + "=" + cookie.value
}
const config = {
//Entry point to the project
entry: [
'webpack/hot/dev-server',
'webpack/hot/only-dev-server',
path.join(__dirname, '/src/app/app.jsx'),
],
//Webpack config options on how to obtain modules
resolve: {
//When requiring, you don't need to add these extensions
extensions: ['', '.js', '.jsx', '.md', '.txt'],
//alias: {
// //material-ui requires will be searched in src folder, not in node_modules
// 'material-ui/lib': path.resolve(__dirname, '../src'),
// 'material-ui': path.resolve(__dirname, '../src'),
//},
//Modules will be searched for in these directories
modulesDirectories: [
// We need /docs/node_modules to be resolved before /node_modules
path.resolve(__dirname, 'node_modules'),
'node_modules',
path.resolve(__dirname, '../src'),
path.resolve(__dirname, 'src/app/components/raw-code'),
path.resolve(__dirname, 'src/app/components/markdown'),
],
},
//Configuration for dev server
devServer: {
contentBase: 'src/www',
devtool: 'eval',
hot: true,
inline: true,
port: 3000,
proxy: {
'/api/*': {target: 'http://localhost:1338', secure: false},
}
},
devtool: 'source-map',
//Output file config
output: {
path: buildPath, //Path of output file
filename: 'app.js', //Name of output file
},
plugins: [
//Used to include index.html in build folder
new HtmlWebpackPlugin({
inject: false,
template: path.join(__dirname, '/src/www/index.html'),
}),
//Allows for sync with browser while developing (like BorwserSync)
new webpack.HotModuleReplacementPlugin(),
//Allows error warninggs but does not stop compiling. Will remove when eslint is added
new webpack.NoErrorsPlugin(),
// The below was commented out after I found out that the fetch polyfill didn't work on Safari
//new webpack.ProvidePlugin({
// 'Promise': 'es6-promise',
// 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch',
//}),
],
externals: {
fs: 'js', // To remove once https://github.com/benjamn/recast/pull/238 is released
},
module: {
//eslint loader
preLoaders: [
{
test: /\.(js|jsx)$/,
loader: 'eslint-loader',
include: [path.resolve(__dirname, '../src')],
exclude: [
path.resolve(__dirname, '../src/svg-icons'),
],
},
],
//Allow loading of non-es
loaders: [
{
test: /\.jsx$/,
loaders: [
'react-hot',
'babel-loader',
],
exclude: /node_modules/,
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
//{
// test: /\.js$/,
// loaders: [
// "transform?brfs",
// 'babel-loader',
// ],
// exclude: /node_modules/,
//},
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.txt$/,
loader: 'raw-loader',
include: path.resolve(__dirname, 'src/app/components/raw-code'),
},
{
test: /\.md$/,
loader: 'raw-loader',
},
{
test: /\.css$/,
loader: 'style-loader!css-loader',
},
{ test: /\.cjsx$/, loaders: ['coffee', 'cjsx']},
{ test: /\.coffee$/, loader: 'coffee' },
],
//postLoaders: [
// {
// loader: "transform?brfs"
// }
//],
},
resolve: {
extensions: ["", ".cjsx", ".coffee", ".js", ".jsx", ".json", ".txt", ".md", ".css"]
},
eslint: {
configFile: '../.eslintrc',
},
}
module.exports = config