forked from scalable-react/scalable-react-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
117 lines (115 loc) · 3.1 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
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'),
],
output: {
path: path.resolve(ROOT_PATH, 'app/build'),
publicPath: '/',
filename: 'bundle.js',
},
module: {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel-loader']
},
{
test: /\.jsx?$/,
loaders: ['eslint-loader'],
enforce: 'pre',
include: path.resolve(ROOT_PATH, './app')
},
{
test: /\.md$/,
use: ['html-loader','markdown-loader']
},
{
test: /\.svg$/,
use: ['babel-loader','svg-react-loader']
},
{
test: /\.json$/,
use: 'json-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: [/\.module\.scss$/],
use: ExtractTextPlugin.extract({
use: [
'css-loader',
'postcss-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [
path.join(ROOT_PATH, 'node_modules')
],
outputStyle: 'compressed'
}
}
]
})
},
{
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-loader?name=[path][name].[hash].[ext]'
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.json', '.scss', '.css'],
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'),
utils: path.resolve(ROOT_PATH, 'app/src/utils')
},
modules: [
path.join(__dirname, 'src'), 'node_modules'
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
new ExtractTextPlugin('[name].[contenthash].css'),
new webpack.HotModuleReplacementPlugin(),
// new NpmInstallPlugin(), Cannot read property 'plugin' of null
new HtmlwebpackPlugin({
title: 'Scalable React Boilerplate',
template: 'config/templates/_index.dev.html',
}),
],
};