mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 05:09:56 +08:00

* feat: basic use of code block by prism * opti: remove codemirror from muya * feat: add highlight to math and frontmatter * feat: import and export in math block, html block, frontmatter, code block * update: paragraph ctrl * feat: copy and paste in new math block and html block * feat: update code block style in dark theme * feat: search and replace in code block * fix: update menu item status when selection changed * opti: optimization of updateCtrl divide it into clickCtrl and inputCtrl * opti: search and replace in code block when no lang selected * opti: copy paste in code block * feat: insert paragraph before or after code block * opti: change emoji.js to emoji.json * feat: auto indent in code block * opti: auto indent in code block * opti: remove the use of snabbdom-virtualize * fix: do not show format float box in code block * opti: emoji picker * update: delete some unused codes * update: electron * use a temp prismjs2 instead of prismjs
173 lines
4.0 KiB
JavaScript
173 lines
4.0 KiB
JavaScript
'use strict'
|
|
|
|
process.env.BABEL_ENV = 'web'
|
|
|
|
const path = require('path')
|
|
const webpack = require('webpack')
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
const VueLoaderPlugin = require('vue-loader/lib/plugin')
|
|
const SpritePlugin = require('svg-sprite-loader/plugin')
|
|
const postcssPresetEnv = require('postcss-preset-env')
|
|
|
|
const proMode = process.env.NODE_ENV === 'production'
|
|
|
|
const webConfig = {
|
|
mode: 'development',
|
|
devtool: '#cheap-module-eval-source-map',
|
|
entry: {
|
|
web: path.join(__dirname, '../src/renderer/main.js')
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.(js|vue)$/,
|
|
enforce: 'pre',
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'eslint-loader',
|
|
options: {
|
|
formatter: require('eslint-friendly-formatter')
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /(katex|github\-markdown|prism[\-a-z]*)\.css$/,
|
|
use: [
|
|
'to-string-loader',
|
|
'css-loader'
|
|
]
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
exclude: /(katex|github\-markdown|prism[\-a-z]*)\.css$/,
|
|
use: [
|
|
proMode ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
{ loader: 'css-loader', options: { importLoader: 1 } },
|
|
{
|
|
loader: 'postcss-loader', options: {
|
|
ident: 'postcss',
|
|
plugins: () => [
|
|
postcssPresetEnv({
|
|
stage: 0
|
|
})
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.html$/,
|
|
use: 'vue-html-loader'
|
|
},
|
|
{
|
|
test: /\.js$/,
|
|
use: 'babel-loader',
|
|
include: [ path.resolve(__dirname, '../src/renderer') ],
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.vue$/,
|
|
use: {
|
|
loader: 'vue-loader'
|
|
}
|
|
},
|
|
{
|
|
test: /\.svg$/,
|
|
use: [
|
|
{
|
|
loader: 'svg-sprite-loader',
|
|
options: {
|
|
extract: true,
|
|
publicPath: '/static/'
|
|
}
|
|
},
|
|
'svgo-loader'
|
|
]
|
|
},
|
|
{
|
|
test: /\.(png|jpe?g|gif)(\?.*)?$/,
|
|
use: {
|
|
loader: 'url-loader',
|
|
query: {
|
|
limit: 10000,
|
|
name: 'imgs/[name].[ext]'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
use: {
|
|
loader: 'url-loader',
|
|
query: {
|
|
limit: 100000,
|
|
name: 'fonts/[name].[ext]'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new SpritePlugin(),
|
|
new HtmlWebpackPlugin({
|
|
filename: 'index.html',
|
|
template: path.resolve(__dirname, '../src/index.ejs'),
|
|
minify: {
|
|
collapseWhitespace: true,
|
|
removeAttributeQuotes: true,
|
|
removeComments: true
|
|
},
|
|
nodeModules: false
|
|
}),
|
|
new webpack.DefinePlugin({
|
|
'process.env.IS_WEB': 'true'
|
|
}),
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
|
new VueLoaderPlugin()
|
|
],
|
|
output: {
|
|
filename: '[name].js',
|
|
path: path.join(__dirname, '../dist/web')
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.join(__dirname, '../src/renderer'),
|
|
'vue$': 'vue/dist/vue.esm.js'
|
|
},
|
|
extensions: ['.js', '.vue', '.json', '.css']
|
|
},
|
|
target: 'web'
|
|
}
|
|
|
|
/**
|
|
* Adjust webConfig for production settings
|
|
*/
|
|
if (proMode) {
|
|
webConfig.devtool = ''
|
|
webConfig.mode ='production'
|
|
|
|
webConfig.plugins.push(
|
|
new MiniCssExtractPlugin({
|
|
// Options similar to the same options in webpackOptions.output
|
|
// both options are optional
|
|
filename: '[name].[hash].css',
|
|
chunkFilename: '[id].[hash].css'
|
|
}),
|
|
new CopyWebpackPlugin([
|
|
{
|
|
from: path.join(__dirname, '../static'),
|
|
to: path.join(__dirname, '../dist/web/static'),
|
|
ignore: ['.*']
|
|
}
|
|
]),
|
|
new webpack.LoaderOptionsPlugin({
|
|
minimize: true
|
|
})
|
|
)
|
|
}
|
|
|
|
module.exports = webConfig
|