mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 23:12:45 +08:00

* update pageage.json, add maintainer * update dep * feat: opti quick insert * update quick insert icon * update pageage.json, add maintainer * update dep * feat: opti quick insert * update quick insert icon * add windows support * fix #576
176 lines
4.1 KiB
JavaScript
176 lines
4.1 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: { importLoaders: 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',
|
|
options: {
|
|
sourceMap: true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
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 = '#nosources-source-map'
|
|
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
|