forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
108 lines (105 loc) · 2.59 KB
/
webpack.config.js
File metadata and controls
108 lines (105 loc) · 2.59 KB
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
'use strict'
process.env.BABEL_ENV = 'renderer'
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const postcssPresetEnv = require('postcss-preset-env')
/** @type {import('webpack').Configuration} */
module.exports = {
mode: 'production',
devtool: 'hidden-nosources-source-map',
optimization: {
emitOnErrors: false,
minimize: true
},
entry: {
renderer: path.join(__dirname, './lib/index.js')
},
module: {
rules: [
{
test: require.resolve(path.join(__dirname, './lib/assets/libs/snap.svg-min.js')),
use: 'imports-loader?this=>window,fix=>module.exports=0'
},
{
test: /(theme\-chalk(?:\/|\\)index|exportStyle|katex|github\-markdown|prism[\-a-z]*|\.theme|headerFooterStyle)\.css$/,
use: [
'to-string-loader',
'css-loader'
]
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { importLoaders: 1 }
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
postcssPresetEnv({ stage: 0 })
]
}
}
}
]
},
{
test: /\.html$/,
use: 'vue-html-loader'
},
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
type: 'asset',
generator: {
filename: 'images/[name].[contenthash:8][ext]'
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
type: 'asset/resource',
generator: {
filename: 'media/[name].[contenthash:8][ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
type: 'asset/resource',
generator: {
filename: 'fonts/[name].[contenthash:8][ext]'
}
}
]
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'index.min.css'
})
],
output: {
filename: 'index.min.js',
libraryTarget: 'umd',
library: 'Muya',
path: path.join(__dirname, './dist')
},
resolve: {
alias: {
snapsvg: path.join(__dirname, './lib/assets/libs/snap.svg-min.js')
},
extensions: ['.js', '.vue', '.json', '.css', '.node'],
fallback: {
fs: false,
path: require.resolve('path-browserify')
}
}
}