-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.hot.config.js
72 lines (66 loc) · 2.08 KB
/
webpack.hot.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
var {resolve} = require('path');
var webpack = require('webpack');
var reactLoader = require('react-hot-loader');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
devtool: 'eval',
context: __dirname + "/app/js",
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:9000',
'webpack/hot/only-dev-server',
'./app.jsx'
],
output: {
filename: "assets/javascripts/app_bundle.js",
path: __dirname + '/app',
pathinfo: true,
publicPath: 'http://localhost:9000/'
},
resolve: {
extensions: ['.webpack.js', '.web.js', '.js', '.jsx']
},
devServer: {
hot: true,
publicPath: '/assets/',
host: 'localhost',
port: 9000,
contentBase: resolve(__dirname, 'app/assets/'),
headers: {
'Access-Control-Allow-Origin': 'http://localhost:3000',
'Access-Control-Allow-Credentials': 'true'
}
},
module: {
// Load the react-hot-loader
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: ['babel-loader?presets[]=es2015&presets[]=react']
},
// Extract css files
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader'})
},
// Optionally extract less files
// or any other compile-to-css language
{
test: /\.less$/,
loader: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader'})
},
{
test: /\.(jpg|png|svg)$/,
loader: 'url-loader'
}
]
},
// Require the webpack and react-hot-loader plugins
plugins: [
new ExtractTextPlugin("assets/stylesheets/app_bundle.css"),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin()
]
};