-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (85 loc) · 2.52 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
var WebpackBundleSizeAnalyzerPlugin = require('webpack-bundle-size-analyzer').WebpackBundleSizeAnalyzerPlugin; 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');
const env = process.env.NODE_ENV;
module.exports = function (env, argv) {
let builddir = argv.mode== 'production' ? 'dist' : 'test';
return {
resolve: {
fallback: {
buffer: require.resolve('buffer/'),
}},
// resolve: { fallback:{ "buffer" : false } },
//externals: ["fs"],
watch: argv.mode != 'production',
target: 'web',
optimization: {
},
mode: argv.mode,
entry: {
"mdsite": './src/viewer.js',
// USER SCRIPTS
"scripts/currentpage": "./src/user_scripts/currentlink.js",
"scripts/bilingual": "./src/user_scripts/bilingual.js",
"scripts/forkme" : "./src/user_scripts/forkme.js",
"scripts/mark_unsaved" : "./src/user_scripts/mark_unsaved.js"
},
devtool: argv.mode != "production" ? 'inline-source-map' : false,
// devServer: argv.mode != "production" ? {contentBase: 'dist'} : {contentBase: 'dist'},
output: {
// filename: '[name].js',
path: path.resolve(__dirname, builddir, "")
},
module: {
rules: [
{
test: /\.svg$/,
type: 'asset/inline'
},
{
test: /\.(less|css|scss)$/,
use: [
'style-loader' ,
'css-loader',
'sass-loader'
],
},
{
test: /\.(woff|ttf)$/,
use: [{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]'
}
}
],
}
]
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new WebpackBundleSizeAnalyzerPlugin('./plain-report.txt'),
new webpack.DefinePlugin({
// Definitions...
'VERSION': JSON.stringify(pkg.version)
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
new HtmlWebpackPlugin({
chunks: ["mdsite"],
filename: 'index.html',
minify: false,
inject: false,
template: path.join(__dirname, "src/templates/index.ejs"),
}
),
// new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/loader/]),
],
};
}