-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.babel.js
113 lines (111 loc) · 3.03 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
/* eslint-disable */
const webpack = require('webpack');
const path = require('path');
const HtmlwebpackPlugin = require('html-webpack-plugin');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const ROOT_PATH = path.resolve(__dirname);
module.exports = {
devtool: 'eval',
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:1337',
'webpack/hot/only-dev-server',
path.resolve(ROOT_PATH, 'app/src/index'),
],
output: {
path: path.resolve(ROOT_PATH, 'app/build'),
publicPath: '/',
filename: 'bundle.js',
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
loaders: ['eslint'],
include: path.resolve(ROOT_PATH, './app')
}
],
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel']
},
{
test: /\.md$/,
loader: "html!markdown"
},
{
test: /\.svg$/,
loader: 'babel!svg-react'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.inline\.scss$/,
loader: 'isomorphic-style-loader!css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]!resolve-url-loader!postcss-loader!sass-loader'
},
{
test: /\.module\.scss$/,
loader: 'style-loader!css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]!resolve-url-loader!postcss-loader!sass-loader'
},
{
test: /\.scss$/,
exclude: [/\.inline\.scss$/, /\.module\.scss$/],
loader: 'style-loader!css-loader!postcss-loader!sass-loader'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
loader: 'url-loader?mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/,
loader: 'file-loader?name=[name].[ext]'
},
{
test: /\.(jpg|png)$/,
loader: 'file?name=[path][name].[hash].[ext]'
}
]
},
sassLoader: {
includePaths: [
'./node_modules',
]
},
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
alias: {
components: path.resolve(ROOT_PATH, 'app/src/components'),
containers: path.resolve(ROOT_PATH, 'app/src/containers'),
pages: path.resolve(ROOT_PATH, 'app/src/pages'),
fragments: path.resolve(ROOT_PATH, 'app/src/fragments'),
utils: path.resolve(ROOT_PATH, 'app/utils'),
config: path.resolve(ROOT_PATH, 'app/src/config')
},
},
postcss: function () {
return {
defaults: [precss, autoprefixer],
cleaner: [autoprefixer({ browsers: [] })]
};
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
new webpack.HotModuleReplacementPlugin(),
new NpmInstallPlugin(),
new HtmlwebpackPlugin({
title: 'Udacity Alumni',
template: 'config/templates/_index.dev.html',
}),
],
};