我正在使用webpack ...我想在webpack.config.js文件中使用第三方库(knockoutjs库),库保存在我的本地目录中
我试过使用
const ojL10n = require("D:/SVN/trunk/core/channel/framework/tmp/ojL10n.js")
但我得到错误...定义未在D中定义
这是我配置文件
"use strict";
require("amd-loader");
const webpack = require("webpack"),
path = require("path");
ojL10n = require("./tmp/ojL10n.js"), //library stored in local
text = require("./tmp/text.js"), //library stored in local
webpackConfigurationObject = {
entry: "./entryModule.js",
target: "node",
mode: "development",
node: {
__dirname: false
},
resolve: {
alias: {
text : text,
ojL10n : ojL10n
},
extensions: [".ts",".js", ".json"]
},
output: {
path: path.join(__dirname, "dest"),
filename: "combinedFile.js",
library: "combinedFile",
libraryTarget: "commonjs2"
},
module: {
rules: [{
test: /\.ts$/,
include: /src/,
exclude: /(node_modules)|(dist)/,
use: {
loader: "babel-loader"
},
parser: { amd: false }
}]
},
externals: {
jquery: {
commonjs2 : "jQuery"
},
knockout: {
commonjs2 : "knockout"
}
}
};
const compiler = webpack(webpackConfigurationObject),
compiler.run(complete);
1条答案
按热度按时间kcugc4gi1#
这个问题我有答案了。
将resolveLoader添加到webpack.config.js文件中