-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (93 loc) · 2.32 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
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
const path = require("path");
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const STATIC_ROOT = path.resolve('./static');
module.exports = {
context: __dirname,
mode: 'development',
entry: {
'main': './static/js/index.js',
'login': './static/js/login.js',
'order': './static/js/order.js',
'serve': './static/js/serve.js',
'status': './static/js/status.js',
},
devtool: 'inline-source-map',
output: {
'path': path.resolve(STATIC_ROOT, "dist/"),
'filename': "[name].bundle.js",
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
{loader: 'style-loader'}, // don't use this in development
{loader: MiniCssExtractPlugin.loader},
{loader: 'css-loader'},
{
loader: 'sass-loader',
options: {
includePaths: [ // add globally reachable scss directories
path.resolve(STATIC_ROOT, "scss"),
path.resolve(STATIC_ROOT, "templates/modules"),
],
}
},
],
},
{
test: /\.css$/,
use: [
'style-loader', // don't use this in development
MiniCssExtractPlugin.loader,
'css-loader',
],
},
{
test: /\.(png|jpe?g|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]'
},
},
],
},
{
test: /\.html$/,
use: [
'file-loader?name=[name].[ext]',
'extract-loader',
'html-loader',
]
},
],
},
plugins: [
new BundleTracker({filename: "./webpack-stats.json"}),
new MiniCssExtractPlugin({
filename: "[name].bundle.css",
chunkFilename: "[id].bundle.css",
}),
],
devServer: {
contentBase: path.resolve(STATIC_ROOT, 'dist'),
compress: true,
port: 9000
}
};