简体   繁体   中英

i can't make works this easy code to run webpack

i learn how to use webpack. I wrote this code in my webpack.config.js

const path= require('path')

module.exports= {
    entry:'./app/assets/scripts/App.js',
    output: {
        filename:'bundled.js',
        path: path.resolve(__dirname,'App')
    },
    mode:'development',
    watch: true, 
};

I wrote this code in my package.json

 { 
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "webpack",
    "test": "echo \"Error: no test specified\" && exit 1"
 },
 "devDependencies":{
    "webpack": "^4.41.0",
    "webpack-cli": "^3.3.9",
    "webpack-dev-server": "^3.9.0"
 }

and this is the code in my App.js

alert("Hello, this is just a test!");

i run npm run dev . i get no errors messages, but the javascript don't run in my index page. Please help me, i don't understand from where the problem comes.

after hours of trying, it seems my index.html VisualCodeStudio started to now that bundled.js exist in proposing it via intellisens. I delete also the main: index.js on my package.json. Now its working, even if i didnt't yet clearly detected what was the problem initially.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM