Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
72 lines (68 loc) · 1.87 KB
/
Copy pathwebpack.config.js
File metadata and controls
72 lines (68 loc) · 1.87 KB
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
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
var FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
// Separate js and css bundles apart. See: https://github.com/webpack-contrib/extract-text-webpack-plugin
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var rootAssetPath = path.resolve("assets");
var outputPath = path.resolve(rootAssetPath, "bundles");
var publicHost = 'http://localhost:8080';
var publicPath = publicHost + '/assets/bundles/';
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : false,
entry: {
app_js: [
path.resolve(rootAssetPath, "js/index")
],
app_css: [
path.resolve(rootAssetPath, 'css/index')
]
},
output: {
path: outputPath,
publicPath: publicPath,
filename: "index.[name].min.js",
},
resolve: {
modules: ['node_modules'],
extensions: ['.js', '.jsx', '.css']
},
module: {
rules: [
{
test: /\.jsx?$/,
include: path.resolve(rootAssetPath, 'js'),
exclude: /(node_modules|__tests__)/,
loaders: ['babel-loader'],
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
{
use: "css-loader",
fallback: "style-loader",
}
),
},
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('index.min.css'),
].concat(
debug ? [
new webpack.HotModuleReplacementPlugin(),
// new FriendlyErrorsWebpackPlugin(),
] : [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
]
),
devServer: {
contentBase: rootAssetPath,
// quiet: true, // required for FriendlyErrorsWebpackPlugin
host: '0.0.0.0',
port: '8080',
}
};