所以我有一个我正在研究的React应用程序,我正在使用Visual Studio构建应用程序(用于后端的ASP.NET Web API 2.0)。我不得不对应用程序进行一些非常重大的更改,所以我为它创建了一个单独的分支。我在新分支中向项目添加了一些JSX文件,当我尝试require
在这样的文件中时:{/ p>
const Reports = require("./Reports/Reports.jsx");
我收到错误:"未捕获错误:找不到模块./Reports/Reports.jsx"在网络浏览器中
似乎webpack没有检测到分支上任何新添加的文件,原因可能是什么?
这是我的webpack配置:
function getWebpackConfig(moreProps) {
var config = {
debug: true,
devtool: 'source-map',
entry: {
main: './src/start.jsx'
},
output: {
path: path.join(__dirname, './dist'),
filename: 'app.bundle.js'
},
module: {
loaders: [{
test: /\.jsx$|\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.less$/,
loader: "style-loader!css-loader!less-loader"
}]
},
resolve: {
alias: {
"~": path.resolve("./src")
},
extensions: ['', '.js', '.jsx']
}
};
config = Object.assign({}, config, moreProps);
return config;
}
这是我的package.json,其中包含安装在项目目录中的node_modules:
{
"name": "internal auditing site",
"version": "1.0.0",
"description": "Web Client for internal auditing site",
"repository": "~company name excluded for StackOverflow~",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-polyfill": "^6.16.0",
"lodash": "^4.11.1",
"moment": "^2.12.0",
"node-uuid": "^1.4.7",
"path": "^0.12.7",
"react": "^15.0.1",
"react-dom": "^15.0.1",
"react-redux": "^4.4.4",
"redux": "^3.4.0",
"redux-thunk": "^2.0.1",
"webpack": "^1.13.3",
"whatwg-fetch": "^0.11.0"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.7.6",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-runtime": "^6.6.1",
"css-loader": "^0.23.1",
"del": "^2.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"gulp": "^3.9.1",
"gulp-replace": "^0.5.4",
"gulp-util": "^3.0.7",
"history": "^2.0.1",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"object-assign": "^4.0.1",
"style-loader": "^0.13.1",
"webpack": "^1.13.3"
}
}
我也不完全确定这是Webpack或Team Foundation Server的问题。