forked from oguimbal/pg-mem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayground.webpack.config.js
More file actions
151 lines (147 loc) · 5.05 KB
/
Copy pathplayground.webpack.config.js
File metadata and controls
151 lines (147 loc) · 5.05 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const webpack = require('webpack');
const path = require('path');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const APP_DIR = path.resolve(__dirname, './playground');
const MONACO_DIR = path.resolve(__dirname, './node_modules/monaco-editor');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const libConfig = require('./webpack.config.js');
const CopyPlugin = require('copy-webpack-plugin');
const mode = process.argv.includes('--prod')
? 'production'
: 'development';
process.env.NODE_ENV = mode;
const ouptutpath = path.resolve(__dirname, 'dist');
require('rimraf').sync(ouptutpath);
const common = {
mode,
devtool: 'source-map',
optimization: {
minimize: true,
namedModules: true,
concatenateModules: true,
},
plugins: [
new MonacoWebpackPlugin({
// available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
languages: ['pgsql']
}),
],
module: {
rules: [
...libConfig.module.rules,
{
test: /\.tsx$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
},
}, {
test: /\.(js|mjs)$/,
include: path.resolve(__dirname, 'node_modules/react-data-grid'),
exclude: /@babel(?:\/|\\{1,2})runtime/,
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
configFile: false,
compact: false,
// this plugins section:
plugins: [
require.resolve("@babel/plugin-proposal-nullish-coalescing-operator"),
require.resolve("@babel/plugin-proposal-optional-chaining"),
],
presets: [
[
require.resolve('babel-preset-react-app/dependencies'),
{ helpers: true },
],
],
}
}, {
test: /\.css$/,
include: APP_DIR,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
options: {
modules: true,
namedExport: true,
},
}],
}, {
test: /\.css$/,
include: MONACO_DIR,
use: ['style-loader', 'css-loader'],
},
{
test: /\.css$/i,
exclude: MONACO_DIR,
use: ['style-loader', 'css-loader'],
// use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.(eot|otf|ttf|woff|woff2)$/,
use: 'file-loader',
},
],
},
};
module.exports = [
{
...common,
resolve: {
extensions: ['.css', ...libConfig.resolve.extensions],
alias: {
'react-dom': '@hot-loader/react-dom',
},
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000
},
plugins: [
new HtmlWebPackPlugin({
template: path.resolve(__dirname, 'playground/index.html'),
filename: 'index.html'
}),
new CopyPlugin({
patterns: [
{ from: 'playground/index.css', to: 'index.css' },
],
}),
new MonacoWebpackPlugin({
// available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
languages: ['pgsql']
}),
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
],
entry: {
playground: ['react-hot-loader/patch', './playground/index.tsx'],
},
output: {
path: ouptutpath,
filename: 'main.js',
},
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
// npm package names are URL-safe, but some servers don't like @ symbols
return `npm.${packageName.replace('@', '')}`;
},
},
},
},
},
},
];