This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
webpack.config.js
103 lines (100 loc) · 2.54 KB
/
webpack.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const path = require('path');
const webpack = require('webpack');
const dotenv = require('dotenv');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = () => {
dotenv.config();
return {
context: path.resolve(__dirname, 'src'),
entry: {
index: './index.jsx',
plugin: './plugin.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
chunkFilename: '[name].chunk.js',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
plugins: ['lodash', '@babel/plugin-syntax-dynamic-import'],
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
corejs: 3,
},
],
],
},
},
},
{
test: /\.(css|scss)$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/,
use: [
'@svgr/webpack',
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
publicPath: '/assets/font/',
outputPath: 'assets/font/',
},
},
],
},
],
},
resolve: {
extensions: ['.jsx', '.js', 'json'],
alias: {
App: path.resolve(__dirname, 'src/app'),
},
},
plugins: [
new HtmlWebpackPlugin({
chunks: ['index'],
template: './index.html',
}),
new webpack.DefinePlugin({
'process.env': {
MARKETPLACE_API_URL: JSON.stringify(process.env.MARKETPLACE_API_URL),
NPM_INSTALL_TOKEN: JSON.stringify(process.env.NPM_INSTALL_TOKEN),
REST_SERVER_URI: JSON.stringify(process.env.REST_SERVER_URI),
},
}),
new webpack.IgnorePlugin({
resourceRegExp: /^esprima$/,
contextRegExp: /js-yaml/,
}),
new webpack.ProvidePlugin({
cookies: 'js-cookie',
'window.cookies': 'js-cookie',
}),
],
devServer: {
host: '0.0.0.0',
port: process.env.SERVER_PORT,
contentBase: false,
disableHostCheck: true,
watchOptions: {
ignored: /node_modules/,
},
},
};
};