UNPKG

1.9 kBJavaScriptView Raw
1/**
2 * Webpack configuration for analyzing a production bundle
3 */
4
5const merge = require('webpack-merge');
6const VirtualModulesPlugin = require('webpack-virtual-modules');
7const webpack = require('webpack');
8const { getPkg, fromCwd } = require('quickenv');
9
10const getEntrypoints = require('./helpers/getEntrypoints.js');
11const getVirtualFiles = require('./helpers/getVirtualFiles.js');
12const MambaFixesPlugin = require('./plugins/MambaFixesPlugin.js');
13const { BUNDLE_NAME, IS_BROWSER } = require('./helpers/consts.js');
14const loaders = require('./helpers/loaders.js');
15
16const PKG = getPkg();
17
18module.exports = merge(require('./config.base.js'), {
19 entry: getEntrypoints(),
20 output: {
21 path: fromCwd('dist', BUNDLE_NAME),
22 },
23 resolve: {
24 modules: [fromCwd('src'), 'node_modules'],
25 alias: (() => {
26 const aliases = {
27 page: fromCwd('node_modules', 'page'),
28 'core-js': fromCwd('node_modules', 'core-js'),
29 '@mamba/pos': fromCwd('node_modules', '@mamba', 'pos'),
30 };
31
32 if (IS_BROWSER) {
33 aliases.__APP_ICON__ = fromCwd('src', PKG.mamba.iconPath);
34 }
35
36 return aliases;
37 })(),
38 },
39 module: {
40 rules: [
41 /** Handle font imports */
42 { test: /\.(eot|woff2?|otf|ttf)$/, use: [loaders.fonts] },
43 /** Handle image imports */
44 { test: /\.(gif|jpe?g|png|ico|svg|bmp)$/, use: [loaders.images] },
45 ],
46 },
47 plugins: [
48 /** If no real 'src/index.js' present, use the default virtual one */
49 new VirtualModulesPlugin(getVirtualFiles()),
50 /** Prepend the Function.prototype.bind() polyfill webpack's runtime code */
51 new MambaFixesPlugin(),
52 new webpack.DefinePlugin({
53 __APP_MANIFEST__: JSON.stringify({
54 name: PKG.name,
55 description: PKG.description,
56 version: PKG.version,
57 slug: `${PKG.mamba.id}-${PKG.name}`,
58 ...PKG.mamba,
59 }),
60 }),
61 ],
62});