1 | const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2 | const { IS_WATCHING } = require('quickenv');
|
3 |
|
4 | const babelrc = require('@mamba/configs/babel/template.js');
|
5 | const { extendPresetEnv } = require('@mamba/configs/babel/utils.js');
|
6 |
|
7 | const svelteConfig = require('@mamba/configs/svelte/index.js');
|
8 |
|
9 | const { IS_DEV } = require('./consts.js');
|
10 |
|
11 | const babelLoaderConfig = {
|
12 | loader: 'babel-loader',
|
13 | options: {
|
14 | sourceMaps: IS_DEV,
|
15 | cacheDirectory: IS_DEV,
|
16 | babelrc: false,
|
17 | ...babelrc,
|
18 | },
|
19 | };
|
20 |
|
21 | module.exports = {
|
22 | babelEsNext: babelLoaderConfig,
|
23 | babelCJS: {
|
24 | ...babelLoaderConfig,
|
25 | options: extendPresetEnv(babelLoaderConfig.options, {
|
26 | modules: 'commonjs',
|
27 | }),
|
28 | },
|
29 | eslint: {
|
30 | loader: 'eslint-loader',
|
31 | options: { emitWarning: IS_DEV },
|
32 | },
|
33 | |
34 |
|
35 |
|
36 |
|
37 | extractCss: IS_WATCHING() ? 'style-loader' : MiniCssExtractPlugin.loader,
|
38 | css: {
|
39 | loader: 'css-loader',
|
40 | options: {
|
41 | sourceMap: IS_DEV,
|
42 |
|
43 | importLoaders: 2,
|
44 | },
|
45 | },
|
46 |
|
47 | postcss: {
|
48 | loader: 'postcss-loader',
|
49 | options: {
|
50 | sourceMap: true,
|
51 | },
|
52 | },
|
53 | resolveUrl: {
|
54 | loader: 'resolve-url-loader',
|
55 | options: {
|
56 | sourceMap: IS_DEV,
|
57 | keepQuery: true,
|
58 | debug: false,
|
59 | },
|
60 | },
|
61 | fonts: {
|
62 | loader: 'url-loader',
|
63 | options: {
|
64 | fallback: 'file-loader',
|
65 | limit: 1,
|
66 | outputPath: 'assets/',
|
67 | name: './fonts/[name].[ext]',
|
68 | },
|
69 | },
|
70 | images: {
|
71 | loader: 'url-loader',
|
72 | options: {
|
73 | fallback: 'file-loader',
|
74 | limit: 1,
|
75 | outputPath: 'assets/',
|
76 | name: './images/[name].[hash:5].[ext]',
|
77 | },
|
78 | },
|
79 | svelte: {
|
80 | loader: 'svelte-loader',
|
81 | options: {
|
82 | emitCss: true,
|
83 | hotReload: IS_DEV,
|
84 |
|
85 | css: false,
|
86 | ...svelteConfig,
|
87 | },
|
88 | },
|
89 | };
|