【发布时间】:2019-04-28 17:44:00
【问题描述】:
我正在尝试使用 node.js 并与 webpack 捆绑来读取 azure-storage 文件。但是,我似乎无法将核心 node.js 模块与 webpack 捆绑在一起。尽管一切都编译没有任何问题,但是我得到了运行时错误。查看附加的运行时错误: Chrome Runtime Errors
有人可以帮忙吗?这是我的 webpack 文件:
const path = require("path");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractSass = new ExtractTextPlugin({
filename: path.relative(process.cwd(), path.join(__dirname, ".", "css", "style.css")),
});
module.exports = env => {
const plugins = [extractSass];
if (env && env.substring(0, 4) === "prod") {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
output: {
comments: false,
},
}),
);
}
return {
entry: __dirname + '/src/sdlTab.tsx',
output: {
path: __dirname + '/dist',
filename: 'bundle.js',
libraryTarget: "amd"
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: "ts-loader"
},
{
test: /\.exec\.js$/,
use: ['script-loader']
},
{
test: /\.scss$/,
use: extractSass.extract({
use: [
{
loader: "css-loader",
options: { importLoaders: 1 },
},
{
loader: "sass-loader",
},
{
loader: "postcss-loader",
},
],
fallback: "style-loader",
}),
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
}
]
},
target: "node",
externals: [
{
react: true,
"react-dom": true
},
// Ignore TFS/*, VSS/*, Favorites/* since they are coming from VSTS host
/^TFS\//,
/^VSS\//
],
plugins: plugins
};
};
任何帮助将不胜感激。谢谢
【问题讨论】:
标签: node.js webpack azure-storage