webpack解决的一些问题

Some issue with webpack resolving

本文关键字:问题 解决 webpack      更新时间:2023-09-26

我尝试使用webpack设置我的小应用程序。OS Debian。当我尝试通过"webpack"编译和构建项目时,我收到这个:http://pastebin.com/gpwkebuq我不知道为什么文件app.js存在于"frontend"文件夹中。我看到这个错误遇到了很多人,为他们解决这个任务的方法不同,但没有人解决我的问题

我的webpack.config.js

const webpack = require('webpack');
module.exports = {
context: __dirname + '/frontend',
entry: {
    app: "./app"
},
output: {
    path: __dirname + '/public',
    filename: "[name].js",
},
watch: true,
watchOptions: {
    aggregateTimeout: 100
},
devtool: "cheap-inline-module-source-map",
plugins: [
],
module: {
    loaders: [{
        test: /'.js$/,
        loader: 'babel'
    }]
},
resolve: {
    moduleDirectories: ['node_modules'],
    extensions: ['', '.js']
},
resolveLoader: {
    moduleDirectories: ['node_modules'],
    moduleTemplates: ['*-loader', '*'],
    extensions: ['', '.js']
},
};

这是我的package.json:http://pastebin.com/pCSCm9VA我的项目结构:

-anotherproj
   -frontend
       -app.js
       -login.js
   -node_modules
   -public
   -webpack.config.js
   -package.json

将条目更新为

entry: {
    app: "./app.js"
},