-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.common.js
53 lines (44 loc) · 1.18 KB
/
webpack.common.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
'use strict';
require('dotenv').config();
const {DefinePlugin} = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const production = process.env.NODE_ENV === 'production';
const webpackConfig = module.exports = {};
webpackConfig.entry = ['babel-polyfill', `${__dirname}/src/main.js`];
webpackConfig.output = {
filename: '[name].[hash].js',
path: `${__dirname}/build`, //changed to root level
publicPath: '/',
};
webpackConfig.plugins = [
new HtmlWebpackPlugin({
title:'React App',
template: `${__dirname}/src/template.html`,
}),
new DefinePlugin({
'process.env': {
API_URL: JSON.stringify(process.env.API_URL),
},
PRODUCTION: production,
}),
];
webpackConfig.module = {};
webpackConfig.module.rules = [
{
test: /\.(png|gif|svg|jpg)$/,
use: [ 'file-loader' ],
exclude: '/node_modules/**',
},
{
exclude: '/node_modules/**',
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [ 'env','stage-0','react'],
plugins: ['transform-react-jsx-source', 'babel-plugin-lodash', ['direct-import', ['mdi-material-ui']]],
cacheDirectory: true,
},
},
},
];