-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.common.js
105 lines (103 loc) · 2.59 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
94
95
96
97
98
99
100
101
102
103
104
105
const path = require('path');
//const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const Dotenv = require('dotenv-webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
var DIST_DIR = path.resolve(__dirname, "./public");
var SRC_DIR = path.resolve(__dirname, "./src");
module.exports = {
entry: SRC_DIR + '/app/index.js',
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
}
}]
},
{
/** for react-native-web-webview */
test: /postMock.html$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
},
{
test: /\.css/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
// include: SRC_DIR,
use: ['url-loader']
},
{
test: /\.html/,
include: SRC_DIR,
use: ['html-loader']
},
{
test: /\.svg$/,
use: ['svg-inline-loader']
},
]
},
plugins: [
//new CleanWebpackPlugin(['dist/*.*']),
new CaseSensitivePathsPlugin(),
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'),
reduxFiles: path.resolve(__dirname, 'src/app/redux'),
misc: path.resolve(__dirname, 'src/app/misc'),
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'),
styles: path.resolve(__dirname, 'src/app/styles'),
'react-native$': 'react-native-web',
'WebView': 'react-native-web-webview',
}
},
devServer: {
historyApiFallback: true,
},
node: {
fs: 'empty',
net: 'empty',
tls: 'empty',
dns: 'empty'
},
output : {
path: DIST_DIR + '/app',
filename: 'bundle.js',
publicPath: '/app'
},
};