-
Notifications
You must be signed in to change notification settings - Fork 80
/
webpack.config.bundle.cjs
53 lines (50 loc) · 1.3 KB
/
webpack.config.bundle.cjs
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
// This webpack config builds lucid for the use in a <script> tag that already
// has React and ReactDOM available as globals
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
mode: isProduction ? 'production' : 'development',
entry: [
path.join(__dirname, 'src', 'index.ts'),
path.join(__dirname, 'src', 'index.less'),
],
output: {
path: path.join(__dirname, 'dist'),
filename: isProduction ? 'lucid.min.js' : 'lucid.js',
libraryTarget: 'var',
library: 'Lucid',
},
module: {
rules: [
{
test: /\.[jt]sx?$/,
loader: 'babel-loader',
include: [path.resolve(__dirname, 'src')],
},
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { sourceMap: !isProduction } },
{ loader: 'postcss-loader', options: { sourceMap: !isProduction } },
{ loader: 'less-loader', options: { sourceMap: !isProduction } },
],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
devtool: isProduction ? false : 'source-map',
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
plugins: [
new MiniCssExtractPlugin({
filename: 'lucid.css',
disable: !isProduction,
}),
],
};