forked from Bahmni/openmrs-module-appointments-frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
83 lines (80 loc) · 2.8 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
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const distDirPath = __dirname + '/dist';
module.exports = {
context: __dirname + "/src",
entry: './init.js',
output: {
path: distDirPath,
filename: 'appointment.js'
},
resolve: {
modules: ["node_modules"]
},
externals: {
"jquery": "jQuery"
},
module: {
rules: [
// Need to export angular and jQuery in window context
// https://stackoverflow.com/questions/38990018/webpack-provideplugin-angular/41564433#41564433
{
test: require.resolve('angular'),
loader: 'exports-loader?window.angular'
},
{
test: require.resolve('jquery/jquery'),
loader: 'exports-loader?window.jQuery'
},
// Need to change `this` to `window` because modernizer assumes `this` always refers to `window` object
{
test: /modernizr.custom/,
use: [
{loader: 'imports-loader?this=>window'}
]
},
{
test: /\.(s?)css$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.ico$/,
loader: 'file-loader?name=[name].[ext]', // <-- retain original file name
},
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/,
loader: 'url-loader',
options: {
limit: 8192,
},
},
{
test: /\.html$/,
use: [
{loader: 'html-loader'}
]
}
]
},
plugins: [
new webpack.ProvidePlugin({
'jQuery': path.join(__dirname, 'node_modules', 'jquery/jquery'),
'angular': path.join(__dirname, 'node_modules', 'angular'),
'ZeroClipboard': path.join(__dirname, 'node_modules', 'zeroclipboard'),
'moment': path.join(__dirname, 'node_modules', 'moment/min/moment-with-locales')
}),
new HtmlWebpackPlugin({
template: __dirname + '/src/index.html',
output: __dirname + '/dist',
inject: 'head'
}),
new webpack.ContextReplacementPlugin(/\.\/locale$/, 'empty-module', false, /js$/),
new CopyPlugin([
{from: __dirname + '/ui/dist/AppointmentStatusHandler.js', to: distDirPath + '/AppointmentStatusHandler.js'},
{from: __dirname + '/i18n/', to: distDirPath + '/i18n'},
{from: __dirname + '/config/', to: distDirPath + '/config'},
])
]
}