This repository has been archived by the owner on Aug 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
93 lines (91 loc) · 2.23 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
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
const path = require('path');
//const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
var Dotenv = require('dotenv-webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
var DIST_DIR = path.resolve(__dirname, "./public");
var SRC_DIR = path.resolve(__dirname, "./src");
module.exports = {
entry: SRC_DIR + '/app/index.js'
,
cache: true,
module: {
rules : [
{
test: /.jsx?$/,
include: SRC_DIR,
//exclude: /(node_modules)/,
use: [{
loader: "babel-loader",
query: {
presets: ["react", "es2015", "stage-3"],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
compact: false
}
}]
},
{
test: /\.css/,
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/,
use: ['svg-inline-loader']
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
// include: SRC_DIR,
use: ['url-loader']
},
{
test: /\.html/,
include: SRC_DIR,
use: ['html-loader']
}
]
},
plugins: [
//new CleanWebpackPlugin(['dist/*.*']),
new HtmlWebpackPlugin({
title: 'Production'
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
"window.jQuery": "jquery",
moment: 'moment'
}),
new Dotenv({
//path: './.env',
// safe: true, load '.env.example' to verify the '.env' variables are all set. Can also be a string to a different file.
systemvars: true
})
],
resolve: {
alias: {
app: path.resolve(__dirname, 'src/app'),
css: path.resolve(__dirname, 'src/app/css'),
images: path.resolve(__dirname, 'src/app/images'),
forms: path.resolve(__dirname, 'src/app/forms'),
extras: path.resolve(__dirname, 'src/app/extras'),
components: path.resolve(__dirname, 'src/app/components'),
views: path.resolve(__dirname, 'src/app/views'),
actions: path.resolve(__dirname, 'src/app/actions'),
assets: path.resolve(__dirname, 'src/app/assets')
}
},
devServer: {
historyApiFallback: true,
},
node: {
fs: 'empty',
net: 'empty',
tls: 'empty',
dns: 'empty'
},
output : {
path: DIST_DIR + '/app',
filename: 'bundle.js',
publicPath: '/app'
},
};