-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.mjs
42 lines (40 loc) · 1.32 KB
/
webpack.config.mjs
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
import path from 'path';
import ReactRefreshPlugin from '@pmmmwh/react-refresh-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
const isDevelopment = process.env.NODE_ENV !== 'production';
export default {
mode: isDevelopment ? 'development' : 'production',
entry: {
main: './sandbox/index.jsx',
},
resolve: {
symlinks: false,
extensions: ['.js', '.jsx', '.mjs', '.cjs'],
fallback: { url: 'url-polyfill' },
alias: {
'react/jsx-dev-runtime': path.resolve('node_modules/react/jsx-dev-runtime.js'),
'@prezly/content-renderer-react-js/styles.css': path.resolve('build/styles/styles.css'),
'@prezly/content-renderer-react-js': path.resolve('build/esm/index.mjs'),
},
},
module: {
rules: [
{
test: /\.jsx?$/,
include: path.resolve('sandbox'),
use: 'babel-loader',
},
{
test: /\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
},
],
},
plugins: [
isDevelopment && new ReactRefreshPlugin(),
new HtmlWebpackPlugin({
filename: './index.html',
template: './sandbox/index.html',
}),
].filter(Boolean),
};