-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
118 lines (99 loc) · 2.46 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require('webpack');
const pkg = require('./package.json');
var coreCSS="/*not generated yet*/"
const env = process.env.NODE_ENV;
module.exports = function (env, argv) {
let builddir = argv.mode== 'production' ? 'dist' : 'test';
return {
watch: argv.mode != 'production',
target: 'web',
optimization: {
},
mode: argv.mode,
entry: {
"imp": './src/editor_launcher.js',
"hatcher" : './src/hatcher.js',
"helpers" : './src/helpers.js'
},
devtool: argv.mode != "production" ? 'inline-source-map' : false,
output: {
// filename: '[name].js',
path: path.resolve(__dirname, builddir, "")
},
module: {
rules: [
{
test: /\.svg$/,
resourceQuery: /raw/,
type: 'asset/source'
},
{
test: /\.svg$/,
resourceQuery: { not: [/raw/] },
type: 'asset/inline'
},
{
test: /\.htm$/,
resourceQuery: /raw/,
type: 'asset/source'
},
{
test: /\.(less|css|scss)$/,
use: [
'style-loader' ,
'css-loader',
'sass-loader'
],
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader"
}
},
{
test: /\.(woff|ttf)$/,
use: [{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]'
}
}
],
}
]
},
plugins: [
new webpack.DefinePlugin({
// Definitions...
'VERSION': JSON.stringify(pkg.version)
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
new HtmlWebpackPlugin({
chunks: ["editor"],
filename: 'index.html',
minify: false,
inject: false,
css: coreCSS,
// scriptLoading: 'defer',
template: path.join(__dirname, "src/templates/index.ejs"),
}
),
new HtmlWebpackPlugin({
chunks: ["hatcher"],
filename: 'hatcher.html',
minify: false,
inject: "body",
template: path.join(__dirname, "src/templates/hatcher.ejs"),
}
),
],
};
}