-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
84 lines (70 loc) · 1.87 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
'use strict';
require('dotenv').config();
const {DefinePlugin, EnvironmentPlugin} = require('webpack');
const CleanPlugin = require('clean-webpack-plugin');
const UglifyPlugin = require('uglifyjs-webpack-plugin');
const webPackConfig = module.exports = {};
const HTMLWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PRODUCTION = process.env.NODE_ENV === 'production';
//=======================================
webPackConfig.entry = `${__dirname}/src/main.js`;
webPackConfig.output = {
path: `${__dirname}/build`,
filename: 'bundle.[hash].js',
},
//=======================================
webPackConfig.plugins = [
new HTMLWebpackPlugin({title : 'intelliSound'}),
new EnvironmentPlugin(['NODE_ENV']),
new DefinePlugin({
__API_URL__ : JSON.stringify(process.env.API_URL),
}),
new ExtractTextPlugin('bundle.[hash].css'),
];
if(PRODUCTION) {
webPackConfig.plugins = webPackConfig.plugins.concat([
new UglifyPlugin(),
new CleanPlugin(),
]);
}
//=======================================
webPackConfig.module = {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.(jpg|gif|png|svg)$/,
use: [{
loader: 'url-loader',
options: {
limit: 10000,
name: 'image/[name].[hash].[ext]',
},
}],
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
use: [
'css-loader',
'resolve-url-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [`${__dirname}/src/style`],
},
},
],
}),
},
],
};
webPackConfig.devtool = PRODUCTION ? undefined : 'eval-source-map';
webPackConfig.devServer = {
historyApiFallback: true,
};