eslint js 文件并启用缓存 --cache (#7330)

* chore: lint js file and use cache to speed up

* chore: autofix and format code
This commit is contained in:
Percy Ma 2023-02-11 23:04:14 +08:00 committed by GitHub
parent 9680294d39
commit ab15c09e26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 207 additions and 207 deletions

View file

@ -1,27 +1,26 @@
const path = require('path')
const webpack = require('webpack')
const pkg = require('./package.json')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
const BundleAnalyzerPlugin = require(
'webpack-bundle-analyzer').BundleAnalyzerPlugin
const TerserPlugin = require('terser-webpack-plugin')
const path = require("path");
const webpack = require("webpack");
const pkg = require("./package.json");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const TerserPlugin = require("terser-webpack-plugin");
module.exports = (env, argv) => {
return {
mode: argv.mode || 'development',
watch: argv.mode !== 'production',
devtool: argv.mode !== 'production' ? 'eval' : false,
mode: argv.mode || "development",
watch: argv.mode !== "production",
devtool: argv.mode !== "production" ? "eval" : false,
output: {
publicPath: "",
filename: '[name].js',
path: path.resolve(__dirname, 'stage/build/export'),
libraryTarget: 'umd',
library: 'Protyle',
libraryExport: 'default',
filename: "[name].js",
path: path.resolve(__dirname, "stage/build/export"),
libraryTarget: "umd",
library: "Protyle",
libraryExport: "default",
},
entry: {
'protyle-method': './src/protyle/method.ts',
"protyle-method": "./src/protyle/method.ts",
},
optimization: {
minimize: true,
@ -38,23 +37,23 @@ module.exports = (env, argv) => {
},
resolve: {
fallback: {
'path': require.resolve('path-browserify'),
"path": require.resolve("path-browserify"),
},
extensions: ['.ts', '.js', '.scss'],
extensions: [".ts", ".js", ".scss"],
},
module: {
rules: [
{
test: /\.ts(x?)$/,
include: [path.resolve(__dirname, 'src')],
include: [path.resolve(__dirname, "src")],
use: [
{
loader: 'ts-loader',
loader: "ts-loader",
},
{
loader: 'ifdef-loader',
loader: "ifdef-loader",
options: {
'ifdef-verbose': false,
"ifdef-verbose": false,
BROWSER: true,
MOBILE: true,
},
@ -64,23 +63,23 @@ module.exports = (env, argv) => {
{
test: /\.scss$/,
include: [
path.resolve(__dirname, 'src/assets/scss'),
path.resolve(__dirname, "src/assets/scss"),
],
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader', // translates CSS into CommonJS
loader: "css-loader", // translates CSS into CommonJS
},
{
loader: 'sass-loader', // compiles Sass to CSS
loader: "sass-loader", // compiles Sass to CSS
},
],
},
{
test: /\.woff$/,
type: 'asset/resource',
type: "asset/resource",
generator: {
filename: '../fonts/JetBrainsMono-Regular.woff',
filename: "../fonts/JetBrainsMono-Regular.woff",
},
},
],
@ -89,15 +88,15 @@ module.exports = (env, argv) => {
// new BundleAnalyzerPlugin(),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
path.join(__dirname, 'stage/build/export')],
path.join(__dirname, "stage/build/export")],
}),
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(argv.mode),
SIYUAN_VERSION: JSON.stringify(pkg.version),
}),
new MiniCssExtractPlugin({
filename: 'base.css',
filename: "base.css",
}),
],
}
}
};
};