如何运行jsdoc wtih网页包?

u91tlkcl  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(220)

上周我开始配置webpack,出现了一个问题:如何使用webpack运行jsdoc生成?
所有jsdoc网页包似乎都已弃用或过时。。。
我的简单配置文件:

const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ESLintPlugin = require('eslint-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

let config = {
    entry: {
        app: ['./src/js/css.js', './src/js/app.js']
    },
    output: {
        filename: 'assets/js/[name].[contenthash].bundle.js',
        path: path.resolve(__dirname, 'dist'),
        clean: true
    },
    devServer: {
        contentBase: path.join(__dirname, 'dist'),
        compress: true,
        port: 9000,
    },
    mode: 'development',
    // mode: 'production',
    devtool: 'inline-source-map',
    module: {
        rules: [
            // LOADER BABEL
            {
                test: /\.m?js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                        targets: ['defaults'],
                        plugins: ['@babel/plugin-proposal-object-rest-spread']
                    }
                }
            },
            // LOADER STYLE + CSS
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"],
            },
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./index.html"
        }),
        new ESLintPlugin({
            extensions: ["js", "jsx", "ts", "tsx"],
        })
    ]
};

let analyzerMode = process.argv.find(param => param === '--analyze');
config.plugins.push(new BundleAnalyzerPlugin({
    openAnalyzer: false,
    defaultSizes: 'gzip',
    analyzerMode: analyzerMode ? 'static' : 'disabled'
}));

module.exports = config;

现在,在我的项目中,可以运行jsdoc src/js/,它将生成包含所有js文档的out文件夹。
如何使用webpack.config.js自动执行此过程命令?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题