简体   繁体   English

如何获取webpack来编译app / js目录中的main.js文件?

[英]How do I get webpack to compile the main.js file in app/js directory?

I am ripping my hair out here, I am trying to create a Reactjs app. 我在这里扯头发,我试图创建一个Reactjs应用程序。 I have created the folder then executed: 我创建了文件夹然后执行:

npm install webpack -g

Then I executed: 然后我执行了:

npm init

Completed the package.json file: 完成package.json文件:

{
  "name": "reactquiz",
  "version": "1.0.0",
  "description": "This is a Reactjs quiz app",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Daniel Cortes",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "6.13.*",
    "babel-loader": "6.2.*",
    "webpack": "^1.13.2"
  },
  "dependencies": {
    "react": "^15.3.1",
    "react-dom": "^15.3.1"
  }
}

Then I executed webpack locally: 然后我在本地执行了webpack:

npm install webpack --save-dev

Then I created the webpack.config.js file: 然后,我创建了webpack.config.js文件:

module.export = {
    entry: [
        './src/index.js'
    ],
    output: {
        path: __dirname,
        filename: 'app/js/main.js'
    },
    module: {
        loaders: [{
            test: /\.jsx?$/,
            loader: 'babel-loader',
            exclude: /node_modules/
        }]
    }

}

And I realized I still do not have a main.js file in app/js. 而且我意识到我在app / js中仍然没有main.js文件。 Please help. 请帮忙。 I have looked at the webpack documentation, I have looked here, I have looked at tutorials. 我看过webpack文档,我看过这里,看过教程。 What is the proper way to install webpack so it generates the file in app/js/main.js? 什么是安装webpack以便在app / js / main.js中生成文件的正确方法是什么?

The filename doesn't look right, the correct format is: 文件名看起来不正确,正确的格式为:

filename: './app/js/main.js'

Additionally, you didn't "execute webpack", you installed it. 另外,您没有“执行webpack”,而是安装了它。 Did you execute the command webpack after that too? 之后,您是否也执行了webpack命令?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 webpack-dev-server 无法真正编译 main.js - webpack-dev-server cannot really compile main.js Webpack Babel 脚本添加到我的索引中。html 文件需要是 src="/main.js" 但是 src="main.js"。 如何正确配置它? - Webpack Babel script added to my index.html file needs to be src="/main.js" but is src="main.js". How can I configure this correctly? 我在 Gatsby 项目中将“main.js”文件放在哪里? - Where do I put “main.js” file in Gatsby project? 如何在没有jquery或不需要main.js文件的情况下使用typed.js? - How do I use typed.js without jquery or needing a main.js file? 如何将外部js集成到Webpack vue.js中的main.js文件中? - How to integrate a external js into the main.js file in Webpack vue.js? 如何在Vue中将Axios导入main.js? - How do I import Axios into main.js in Vue? 如何发送和接收 ajax 请求而不是从 main.js 文件中抓取代码? - How do I send and receive the ajax request instead of grabbing the code from the main.js file? 如何从Webpack运行节点main.js - How to run node main.js from webpack Vite.js 应用程序中“main.js”文件的用途是什么? - What is the purpose of the 'main.js' file in a Vite.js app? 在Webpack中,如何通过单个条目main.js(文件中包含多个CSS文件)获得多个输出? - In Webpack, how to get multiple outputs with a single entry main.js(having multiple css files inside files)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM