如何限制webpack的范围

时间:2018-09-13 06:11:01

标签: javascript node.js typescript webpack

我目前正在尝试在我的后端中实现打字稿,但是由于它是我的新手,所以我试图在测试文件夹中逐一找出问题,但是似乎webpack正在占用我的所有文件并尝试阅读它们,这给了我类似以下错误:

Duplicate identifierModule '"xxxx"' has no default exportCannot find name 'Proxy'.Cannot redeclare block-scoped variable 'xxxx'.

这是我的配置文件(出于某种原因仍使用webpack3):

"use strict"
const path = require("path")
// const utils = require("./utils")
// const config = require("../config")
var fs = require("fs")
const NodemonPlugin = require("nodemon-webpack-plugin")
const nodeExternals = require("webpack-node-externals")

function resolve(dir) 
{
    return path.join(__dirname, "..", dir)
}

module.exports = {
    context: path.resolve(__dirname, "../src/server/test"),
    entry: "./test.ts",
    output: {
        path: path.resolve(__dirname, "../src/server/test"),
        filename: "bundle.js",
    },
    plugins: [
        // new NodemonPlugin(),
    ],
    resolve: {
        extensions: [".js",".ts", ".tsx"],
        alias: {
            "@": resolve("src"),
            "#": resolve("src/server")
        }
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: "babel-loader",
                include: [resolve("src"), resolve("test")]
            },
            {
                test: /\.tsx?$/,
                loader: "ts-loader",
            },
        ]
    },
    externals: [
        nodeExternals()
    ],
    target: "node"
}

0 个答案:

没有答案