This repository has been archived by the owner on Oct 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.app.config.js
70 lines (63 loc) · 1.86 KB
/
webpack.app.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
/* eslint-disable */
var webpack = require('webpack');
var path = require('path');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var rootDir = process.cwd();
var entry = path.resolve(rootDir, 'app/app.js');
var outDir = path.resolve(rootDir, 'app/build');
var isProd = process.env.NODE_ENV === 'production';
var analyzeBundle = process.env.ASTRO_ANALYZE === 'true';
var config = {
entry: entry,
output: {
filename: 'app.js',
path: outDir
},
resolve: {
alias: {
astro: path.resolve(rootDir, 'node_modules/mobify-progressive-app-sdk/js/src/'),
vendor: path.resolve(rootDir, 'node_modules/mobify-progressive-app-sdk/js/vendor/'),
bluebird: path.resolve(rootDir, 'node_modules/bluebird')
}
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
new webpack.LoaderOptionsPlugin({
options: {
eslint: {
configFile: path.resolve(__dirname, '.eslintrc.yml'),
formatter: require('eslint/lib/formatters/unix')
}
}
})
],
module: {
rules: [{
test: /\.js$/,
enforce: 'pre',
use: ['eslint-loader'],
exclude: /node_modules/
}, {
test: /\.js$/,
use: ['babel-loader'],
include: [
path.resolve(rootDir, 'node_modules/mobify-progressive-app-sdk/js'),
path.resolve(rootDir, 'app')
]
}]
}
};
if (!isProd) {
config.devtool = 'inline-source-maps';
}
if (analyzeBundle) {
config.plugins = config.plugins.concat([
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: true
})
]);
}
module.exports = config;