This repository has been archived by the owner on Nov 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·97 lines (90 loc) · 2.22 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
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
entry: ['babel-polyfill', './src/index.jsx'],
output: {
path: path.resolve(__dirname, './build'),
publicPath: '/',
filename: '[name].js',
chunkFilename: '[name].[chunkhash].js',
},
devtool: 'source-map',
module: {
loaders: [{
test: /\.(js|jsx)$/,
loaders: ['babel-loader', 'stylelint-custom-processor-loader'],
exclude: /node_modules/,
}, {
test: /\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
'sass-loader',
],
}, {
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
}),
}, {
test: /\.(png|jpg|gif)$/,
loaders: ['file-loader', 'image-webpack-loader'],
}, {
test: /\.(ttf|eot|woff|woff2)$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
},
}, {
test: /\.svg$/,
use: [
{
loader: 'babel-loader',
},
{
loader: 'react-svg-loader',
options: {
jsx: true,
},
},
],
},
],
},
plugins: [
// Include all scripts to html as diferent script tags.
new HtmlWebpackPlugin({
template: 'src/index.html',
}),
// Create visualization of javascript files used in project.
new BundleAnalyzerPlugin({
openAnalyzer: false,
}),
new ExtractTextPlugin('styles.css'),
new webpack.DefinePlugin({
__ROOT_URL__: JSON.stringify("http://localhost:8080/"),
}),
new LodashModuleReplacementPlugin({
shorthands: true,
}),
],
resolve: {
extensions: ['.js', '.jsx'],
},
devServer: {
contentBase: path.join(__dirname, 'public'),
compress: true,
port: 8080,
historyApiFallback: true,
},
};