forked from wordpress-clients/hybrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
96 lines (93 loc) · 2.89 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
84
85
86
87
88
89
90
91
92
93
94
95
96
var path = require('path'),
fs = require('fs'),
webpack = require("webpack"),
libPath = path.join(__dirname, 'lib'),
wwwPath = path.join(__dirname, 'www'),
pkg = require('./package.json'),
parserXml = require('xml2js'),
projectConfig = require('./config.json'),
HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: path.join(libPath, 'index.coffee'),
output: {
path: wwwPath,
filename: 'bundle-[hash:6].js'
},
module: {
loaders: [{
test: /[\/]angular\.js$/,
loader: 'expose?angular!exports?window.angular'
}, {
test: /[\/]highlight\.js$/,
loader: 'expose?hljs'
}, {
test: /[\/]imgcache\.js$/,
loader: 'expose?ImgCache'
}, {
test: /[\/]ionic\.js$/,
loader: 'exports?ionic' // For non commonJs
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /\.md$/,
loader: "html!markdown"
}, {
test: /\.json$/,
loader: "json"
}, {
test: /\.(png|jpg)$/,
loader: 'file?name=img/[name].[ext]' // inline base64 URLs for <=10kb images, direct URLs for the rest
}, {
test: /\.css$/,
loader: "style!css"
}, {
test: /\.coffee$/,
loader: "ng-annotate?add=true!coffee"
}, {
test: /\.scss$/,
loader: "style!css!autoprefixer!sass"
}, {
test: [/Roboto\.ttf/, /Roboto\.woff/, /Roboto\.woff2/],
loader: 'file?name=fonts/[name].[ext]'
}, {
test: [/ionicons\.svg/, /ionicons\.eot/, /ionicons\.ttf/, /ionicons\.woff/],
loader: 'file?name=fonts/[name].[ext]'
}]
},
resolve: {
extensions: ['', '.js', '.json', '.scss', '.coffee', '.html'],
root: [
path.join(__dirname, 'src'),
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'bower_components')
],
moduleDirectories: [
'bower_components',
'node_modules'
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
pkg: pkg,
appVersion: getAppVersion(),
template: path.join(libPath, 'index.html')
}),
new webpack.ContextReplacementPlugin(/moment\/locale$/, getRegexAutorizedLanguages()),
new webpack.DefinePlugin({
IS_PROD: false
})
]
};
function getRegexAutorizedLanguages() {
return new RegExp(Object.keys(projectConfig.translation.available).join('|'));
}
function getAppVersion() {
var version,
config = fs.readFileSync(__dirname + '/config.xml');
parserXml.parseString(config, function(err, result) {
version = result.widget.$.version;
});
return version;
}