-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.babel.js
111 lines (109 loc) · 2.98 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
var path = require('path');
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
const ENV = process.env.NODE_ENV || 'development';
var config = {
context: path.join(__dirname),
entry: {
app: [
'./src/index.js',
'global_styles/_main.scss'
]
},
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.(ico|jpg|jpeg|png|eot|ttf|woff|svg|less)/,
loader: 'file-loader'
}, {
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
}, {
test: /\.(scss|css)$/,
include: /components\/partials\//,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [{
loader: "css-loader"
}, {
loader: "sass-loader"
}]
})
}, {
test: /\.(scss|css)$/,
exclude: /components\/partials\//,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [{
loader: "css-loader"
}, {
loader: "sass-loader"
}]
})
}, {
test: /modernizr\.min\.js$/,
loader: "imports?this=>window,html5=>window.html5!exports?window.Modernizr"
}
],
},
resolve: {
extensions: [
'*', '.scss', '.js', '.json'
],
modules: [
'node_modules',
path.resolve(__dirname, './node_modules')
],
alias: {
'base': path.resolve(__dirname, './src/'),
'components': path.resolve(__dirname, './src/components/'),
'assets': path.resolve(__dirname, './src/assets/'),
'global_styles': path.resolve(__dirname, './src/assets/styles/'),
'constants': path.resolve(__dirname, './src/constants'),
'api': path.resolve(__dirname, './src/api/'),
'app': path.resolve(__dirname, './src/components/app'),
'pages': path.resolve(__dirname, './src/components/pages'),
'layout': path.resolve(__dirname, './src/components/layout'),
'modules': path.resolve(__dirname, './src/components/modules')
}
},
plugins: ([
new webpack.NoEmitOnErrorsPlugin(),
new webpack.LoaderOptionsPlugin({
debug: ENV,
options: {
context: __dirname
}
}),
new ExtractTextPlugin({
filename: 'style.css',
disable: false,
allChunks: true
}),
new HtmlWebpackPlugin({
template: path.resolve('./src/', 'index.html'),
favicon: path.resolve('./src/', 'assets/images/favicon.ico'),
minify: {
collapseWhitespace: true
}
})
// new webpack.HotModuleReplacementPlugin()
]),
devtool: ENV === 'production' ? 'source-map' : 'source-map',
devServer: {
port: process.env.PORT || 3000,
contentBase: './',
historyApiFallback: true
}
};
module.exports = config;