无法将插件添加到Webpack配置文件

时间:2019-06-11 12:47:22

标签: webpack ecmascript-6 webpack-2 webpack-4 html-webpack-plugin

我正在尝试向我的项目中添加一个用于生成robots.txt的插件:

https://www.npmjs.com/package/robotstxt-webpack-plugin

这是我当前的webpack配置:

var path = require("path");
var DIST_DIR = path.resolve(__dirname, "public");
var SRC_DIR = path.resolve(__dirname, "src");

const RobotstxtPlugin = require("robotstxt-webpack-plugin");
const options = {}; // see options below

var config = {
    //entry: [ SRC_DIR + "/app/index.js"],
    entry: [ SRC_DIR + "/app/client.js"],
    output: {
        path: DIST_DIR ,
        filename: "bundle.js"
    },
    module: {
        loaders: [
            {
                test: /\.js?/,
                include: SRC_DIR,
                loader: "babel-loader",
                query: {
                    "plugins": ["transform-decorators-legacy", "transform-class-properties","transform-decorators"],
                    presets: [
                        "react",
                        "es2015",
                        "stage-2",
                        ['env', {targets: {browsers: ['last 3 versions']}}]]
                }
            }, {
                test: /\.s?css/,
                include: SRC_DIR,
                loaders: ["style-loader","css-loader","sass-loader"]
            },
            { test: /\.(svg|woff|ttf|wav|mp3)$/, loader: "file-loader" },
            {
                test: /\.(png|jpe?g|gif)$/,
                loader: 'url-loader?limit=25000&name=img/[name].[ext]'
            }
        ]
    }
};

现在,我需要将robotstxt-webpack-plugin添加到此webpack配置中。问题是我需要它在公共文件夹中创建robots.txt,但是我没有任何入口点。

module.exports = {
  plugins: [new RobotstxtPlugin(options)]
};

当我将其添加为单独的module.export时,它抱怨没有入口点,但是我没有任何入口点,我只是希望文件在公共文件夹中生成。 谁能阐明这一点?我想念什么吗?

0 个答案:

没有答案