This repository was archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
87 lines (76 loc) · 2.38 KB
/
Copy pathwebpack.config.js
File metadata and controls
87 lines (76 loc) · 2.38 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var port = process.env.PORT || 8081;
function make(build) {
var entry = [
'./index.js'
];
if (!build) {
entry.unshift(
'webpack-dev-server/client?http://localhost:' + port,
'webpack/hot/only-dev-server'
);
}
var plugins = [
new webpack.EnvironmentPlugin('NODE_ENV'),
new ExtractTextPlugin('assets/[contenthash].css', {
allChunks: true
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
})
];
if (!build) {
plugins.unshift(new webpack.HotModuleReplacementPlugin());
} else {
plugins.push(
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
}
return {
devtool: 'cheap-module-source-map',
context: __dirname + '/src',
entry: entry,
output: {
filename: 'assets/[hash].js',
path: path.resolve('./dist'),
libraryTarget: 'umd'
},
module: {
loaders: [{
test: /\.js$/,
loader: 'babel-loader?optional[]=runtime&stage=0',
exclude: /(node_modules|bower_components)/
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=2&localIdentName=[name]__[local]___[hash:base64:5]!autoprefixer-loader?{browsers:["last 2 version", "ie >= 10"]}!sass-loader', {
publicPath: '../'
})
}, {
test: /\.svg$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml&name=assets/[sha512:hash:base64:7].[ext]'
}, {
test: /\.png$/,
loader: 'url-loader?limit=10000&mimetype=image/png&name=assets/[sha512:hash:base64:7].[ext]'
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff&name=assets/[sha512:hash:base64:7].[ext]'
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&name=assets/[sha512:hash:base64:7].[ext]'
}, {
test: /\.html$/,
loader: 'html'
}]
},
resolve: {
modulesDirectories: ['node_modules', 'bower_components']
},
plugins: plugins
};
}
module.exports = make(process.env.NODE_ENV === 'production');