-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
97 lines (93 loc) · 2.29 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
var path = require('path');
var webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractSass = new ExtractTextPlugin({
filename: "[contenthash][name].css",
disable: process.env.NODE_ENV === "development"
});
const plugins = {
production: [
new webpack.optimize.UglifyJsPlugin({
compress: true
}),
new webpack.EnvironmentPlugin('NODE_ENV')
/*extractSass,*/
],
development: [
new webpack.optimize.UglifyJsPlugin({
compress: true
})
]
}
module.exports = {
context: __dirname + "/src",
entry: {
app: './main.jsx'
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].bundle.js'
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
app: path.resolve(__dirname, 'src/'),
controllers: path.resolve(__dirname, 'src/controllers/'),
components: path.resolve(__dirname, 'src/components/'),
utility: path.resolve(__dirname, 'src/utility/'),
constants: path.resolve(__dirname, 'src/constants/')
}
},
module: {
rules: [
{
test: /\.eot$|\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$|\.txt$/,
loader: "file-loader?name=[path][name].[ext]"
},
{
enforce: "pre",
test: /\.(js|jsx)$/,
exclude: ['node_modules', 'data'],
loader: 'eslint-loader'
},
{
test: /\.(js|jsx)$/,
exclude: ['node_modules', 'data'],
loader: 'babel-loader',
query: {
presets: [
['es2015', {"modules": false}],
'react'
],
plugins: [require('babel-plugin-transform-object-rest-spread')]
}
},
{
test: /\.(css|scss)$/,
loader: 'style-loader!css-loader!sass-loader'
},
/* {
test: /\.(css|scss)$/,
loader: extractSass.extract({
use: [
{
loader: "css-loader"
}, {
loader: "sass-loader"
}],
fallback: "style-loader"
})
},*/
{
test: /\.html$/,
loader: 'file-loader?name=[name].[ext]!extract-loader!html-loader'
}
]
},
devServer: {
contentBase: path.join(__dirname, "src"),
port: 9000,
host: '0.0.0.0'
},
devtool: "source-map"
}