我试图制作一个包含最新软件包的样板(请不要发布链接到#34;非常好的样板文件",我的需求非常具体)。我试图升级并使用webpack 3,我按照指示进行迁移,我已经走到了尽头,事情在webpack 1中运行良好。
package.json的相关部分
'use strict';
var webpack = require("webpack");
const path = require("path");
module.exports = {
context: __dirname,
entry: [
'jquery/dist/jquery.min',
'foundation-sites/dist/js/foundation.min',
'./app/app',
],
output: {
path: __dirname,
filename: './public/bundle.js'
},
resolve: {
modules: [__dirname, 'node_modules'],
alias: {
Main: 'app/components/Main.jsx',
applicationStyles: 'app/styles/app.scss',
},
extensions: ['*','.js','.jsx','.scss']
},
externals: {
jquery: 'jQuery'
},
plugins: [
new webpack.ProvidePlugin({
'$': 'jquery',
'jQuery': 'jquery',
'window.jQuery': 'jquery'
})
],
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['react', 'env']
}
},
{
test:/\.(s*)css$/,
use:['style-loader','css-loader', 'sass-loader'],
options: {
includePaths: path.resolve(__dirname,'./node_modules/foundation-sites/scss')
}
}
]
},
devtool: 'cheap-module-eval-source-map',
};
webpack.config.js
ERROR in ./app/app.jsx
Module parse failed: F:\tmp\BP\app\app.jsx Line 13: Unexpected token <
You may need an appropriate loader to handle this file type.
|
| ReactDOM.render(
| <Router history={hashHistory}>
| <Route path="/" component={Main}>
| </Route>
@ multi main
ERROR in ./~/jquery/dist/jquery.min.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\andro\AppData\Roaming\npm\node_modules\webpack\buildin\amd-options.js in F:\tmp\BP\node_modules\jquery\dist
@ ./~/jquery/dist/jquery.min.js 2:86650-86660
当我运行webpack
时,我收到此错误isMember(myArr, SIZE - 1, numSearched)
我认为问题可能是因为 resolve.extentions ,我试图添加空字符串,但webpack3不允许,我认为这就是使webpack无法找到文件的原因,因为在搜索文件时,它会在文件末尾连接*并输出&#34;无法找到文件&#34;。如果我向任何条目文件添加正确的扩展名,它也无法找到它们。 我甚至尝试用&#34;打开git bash作为管理员&#34;选项认为它可能是一个权利问题,同样的错误。
编辑:添加了项目结构图。
提前致谢:)