-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.common.js
117 lines (108 loc) · 2.67 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
106
107
108
109
110
111
112
113
114
115
116
117
'use strict';
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
let basePath = path.join(__dirname, '/');
let fs = require('fs');
const MATOMO_VERSION = process.env.MATOMO_VERSION
? process.env.MATOMO_VERSION
: 'Test';
let config = {
entry: {
main: basePath + '/app/js/main.js',
signin: basePath + '/app/js/signin.js',
manual: basePath + '/app/js/manual.js'
},
output: {
// Output directory
path: basePath + '/dist/',
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js'
},
module: {
noParse: /node_modules\/json-schema\/lib\/validate\.js/, // <-- This
rules: [
{
test: /\.js$/,
use: [
{
loader: 'angular1-templateurl-loader'
}
],
exclude: [/.*angular-foundation-6./] // uses $templatecache so dont replace
},
{
test: /\.html$/,
loader: 'raw-loader',
options: {
esModule: false
}
},
{
test: /.(ttf|otf|eot|woff(2)?)(\?[a-z0-9]+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/', // where the fonts will go
publicPath: 'fonts/' // override the default path
}
}
]
},
{
test: /\.(png|jp(e*)g|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: 'images/[hash]-[name].[ext]'
}
}
]
}
]
},
resolve: {
alias: {
'gemtc-web': basePath + '/app/js',
app: basePath + '/app/js/app'
},
modules: [
// Files path which will be referenced while bundling
'node_modules',
basePath + '/app'
],
extensions: ['.css', 'html', '.js', '.json'] // File types
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'app/index.ejs',
inject: 'head',
chunks: ['main'],
matomo: fs.readFileSync(
require.resolve(basePath + '/app/matomo' + MATOMO_VERSION + '.html')
)
}),
new HtmlWebpackPlugin({
filename: 'manual.html',
template: 'app/manual.ejs',
inject: 'head',
chunks: ['manual'],
matomo: fs.readFileSync(
require.resolve(basePath + '/app/matomo' + MATOMO_VERSION + '.html')
)
}),
new CleanWebpackPlugin()
],
optimization: {
splitChunks: {
chunks: 'all',
name: false
}
}
};
module.exports = config;