Issues with getting started with webpack 4

前端 未结 6 572
抹茶落季
抹茶落季 2020-12-14 16:21

I am following the tutorial exactly as given here . But I am amazed that the docs seems outdated. e.g

npx webpack src/index.js dist/bundle.js fails with

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 16:51

    In webpack config file:

    const isProd = process.env.NODE_ENV === 'production';
    module.exports = {
      ***
      mode: isProd ? 'production' : 'development'
      ***
    };
    

    In package.json:

    ***
    "scripts": {
       "dev": "node ./app.js",
       "prod": "cross-env NODE_ENV=production npm run dev",
       ***
    },
    ***
    "dependencies": {
       "cross-env": "^7.0.2",
       ***
    }
    ***
    

提交回复
热议问题