-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
87 lines (81 loc) · 2.17 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
var path = require('path');
var HtmlwebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');
var merge = require('webpack-merge');
var stylelint = require('stylelint');
var cssnext = require('postcss-cssnext');
var configSuitcss = require('stylelint-config-suitcss');
var lost = require('lost');
var postcssReporter = require('postcss-reporter');
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
app: path.join(__dirname, 'app'),
build: path.join(__dirname, 'build')
};
process.env.BABEL_ENV = TARGET;
var common = {
entry: [
'webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port
'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors
PATHS.app
],
resolve: ['', '.js', '.jsx'],
module: {
preLoaders: [
{
test: /\.css$/,
loader: 'postcss',
include: PATHS.app
},
{
test: /\.js?$/,
loader: 'eslint!jscs',
include: PATHS.app
}
],
loaders: [
{
test: /\.css$/,
loader: 'style!css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
include: PATHS.app
},
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'react-hot!babel',
include: PATHS.app
}
]
},
postcss: function () {
return [stylelint(configSuitcss), lost, postcssReporter, cssnext];
},
plugins: [
new HtmlwebpackPlugin({
// Replace with the title of your project
title: 'React Frontend Starter Kit'
})
]
};
if(TARGET === 'start' || !TARGET) {
module.exports = merge(common, {
devtool: 'eval-source-map',
devServer: {
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
// To mute the output in the console, uncomment the 'quiet' property below
// quiet: true,
// display only errors to reduce the amount of output
stats: 'errors-only',
// parse host and port from env so this is easy
// to customize
host: process.env.HOST,
port: process.env.PORT
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
});
}