-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
67 lines (62 loc) · 1.67 KB
/
webpack.dev.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
// const MiniCssExtractPlugin = require("mini-css-extract-plugin");
// const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const path = require('path');
require('dotenv').config({ path: path.resolve(process.cwd(), '.env.development') });
require('dotenv').config();
const webpack = require('webpack');
const port = 9020;
const openBrowser = false;
// inject envs
let plugins = [
new webpack.ProvidePlugin({m: "mithril"})
];
// let plugins = [new MiniCssExtractPlugin()];
let envs = {};
Object.keys(process.env).filter(key => key.startsWith('MITHRIL_')).forEach(key => {
envs[key] = JSON.stringify(process.env[key]);
});
plugins.push(new webpack.DefinePlugin(envs));
let app = ['./src/index.js'];
let rules = [];
// let rules = [{
// test: /\.css$/i,
// use: ["style-loader", "css-loader"],
// // test: /.s?css$/,
// // // test: /\.css$/i,
// // use: [MiniCssExtractPlugin.loader,"style-loader", "css-loader"],
// }];
module.exports = {
entry: {
app: app,
},
output: {
filename: "build/bundle.min.js",
path: path.resolve(__dirname, ''),
publicPath: "/",
},
mode: 'development',
devtool: 'source-map',
devServer: {
port: port,
open: openBrowser,
historyApiFallback: {
index: 'index.html',
},
// proxy: {
// "/api": "http://localhost:3750"
// },
static: 'public',
},
// optimization: {
// minimize: true,
// minimizer: [
// // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
// // `...`,
// new CssMinimizerPlugin(),
// ],
// },
plugins: plugins,
module: {
rules: rules,
},
};