forked from maxGraph/maxGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
45 lines (43 loc) · 1.3 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
// Generated using webpack-cli http://github.com/webpack-cli
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// hack to get the webpack mode
const isDevMode = !process.argv.includes('--mode=production');
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
devServer: {
static: './dist',
},
module: {
rules: [
{
test: /\.css$/i,
use: [isDevMode ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader'],
},
// @maxgraph/core is a dependency of this project but don't declare imports with js extension
// use this workaround to make webpack happy: https://github.com/webpack/webpack/issues/11467#issuecomment-691873586
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: './favicon.svg', to: 'favicon.svg' }],
}),
new HtmlWebpackPlugin({
template: 'index.html',
}),
].concat(isDevMode ? [] : [new MiniCssExtractPlugin()]),
};