-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathwebpack.config.mjs
More file actions
64 lines (61 loc) · 1.65 KB
/
Copy pathwebpack.config.mjs
File metadata and controls
64 lines (61 loc) · 1.65 KB
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
import * as path from 'path';
import { fileURLToPath } from 'url';
import 'webpack-dev-server';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
* Webpack's configuration.
* See https://webpack.js.org/configuration/
*
* @param {Object} env - Environment options
* @param {boolean} [env.production] - Production target flag
* @returns {import('webpack').Configuration}
*/
const config = (env) => {
return {
mode: env.production ? 'production' : 'development',
entry: {
main: './src/index.js',
},
module: {
parser: {
javascript: {
url: false,
},
},
rules: [
{
test: /\.(?:js|mjs|cjs)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
// Options are specified in the .babelrc.json file
},
},
{
test: /\.ts(x)?$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
},
},
],
},
resolve: {
extensions: [
'.js',
'.ts',
],
fallback: {
fs: false,
},
},
devtool: 'source-map',
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
};
};
export default config;