forked from wordpress-clients/hybrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
114 lines (108 loc) · 3.7 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var path = require('path'),
fs = require('fs'),
_ = require('lodash'),
webpack = require("webpack"),
libPath = path.join(__dirname, 'lib'),
wwwPath = path.join(__dirname, 'www'),
pkg = require('./package.json'),
cordovaLib = require('cordova').cordova_lib,
deepExtend = require('deep-extend'),
CSON = require('cson'),
projectConfig = deepExtend(CSON.requireFile('./config/config.default.cson'), CSON.requireFile('./config/config.cson')),
HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: path.join(libPath, 'index.coffee'),
output: {
path: wwwPath,
filename: 'bundle-[hash:6].js'
},
module: {
noParse: [/autoit.js/],
loaders: [{
test: /[\/]highlight\.js$/,
loader: 'expose?hljs'
}, {
test: /[\/]imgcache\.js$/,
loader: 'expose?ImgCache'
}, {
test: /[\/]ionic\.js$/,
loader: 'exports?ionic' // For non commonJs
}, {
test: /service-worker\.js$/,
loaders: [
'file-loader?name=[name].[ext]',
`string-replace-loader?search=SERVICE_WORKER_VERSION&replace="${getAppVersion()}"`
],
include: libPath
}, {
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: "ng-annotate?add=true!babel"
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /\.json$/,
loader: "json"
}, {
test: /\.cson$/,
loader: "cson"
}, {
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', '.cson', '.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,
serviceWorkerEnabled: projectConfig.serviceWorker.enabled,
appVersion: getAppVersion(),
template: path.join(libPath, 'index.html')
}),
new webpack.ContextReplacementPlugin(/moment\/locale$/, getRegexAutorizedLanguages()),
// new webpack.IgnorePlugin(getRegexAutorizedProgramationLanguages()),
new webpack.DefinePlugin({
IS_PROD: false,
IS_TECH: (projectConfig.syntaxHighlighter.enabled)
})
]
};
function getRegexAutorizedLanguages() {
return new RegExp(projectConfig.translation.displayed.join('|'));
}
// function getRegexAutorizedProgramationLanguages() {
// var completeList = [];
// return new RegExp(_.intersection(completeList, projectConfig.syntaxHighlighter.languages).join('|'));
// }
function getAppVersion() {
var config = new cordovaLib.configparser(__dirname + '/config.xml');
return config.version();
}