1 |
|
2 |
|
3 |
|
4 |
|
5 | const merge = require('webpack-merge');
|
6 | const VirtualModulesPlugin = require('webpack-virtual-modules');
|
7 | const webpack = require('webpack');
|
8 | const { getPkg, fromCwd } = require('quickenv');
|
9 |
|
10 | const getEntrypoints = require('./helpers/getEntrypoints.js');
|
11 | const getVirtualFiles = require('./helpers/getVirtualFiles.js');
|
12 | const MambaFixesPlugin = require('./plugins/MambaFixesPlugin.js');
|
13 | const { BUNDLE_NAME, IS_BROWSER } = require('./helpers/consts.js');
|
14 | const loaders = require('./helpers/loaders.js');
|
15 |
|
16 | const PKG = getPkg();
|
17 |
|
18 | module.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 |
|
42 | { test: /\.(eot|woff2?|otf|ttf)$/, use: [loaders.fonts] },
|
43 |
|
44 | { test: /\.(gif|jpe?g|png|ico|svg|bmp)$/, use: [loaders.images] },
|
45 | ],
|
46 | },
|
47 | plugins: [
|
48 |
|
49 | new VirtualModulesPlugin(getVirtualFiles()),
|
50 |
|
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 | });
|