问答详情
源自:2-1 建立项目的 webpack 配置文件

为什么打包失败了

照着步骤来执行命令还是失败了,

D:\Work\webpack-demo>webpack

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

 - configuration.output.path: The provided value "./dist/js" is not an absolute path!

   -> The output directory as **absolute path** (required).


提问者:代码_从入门到放弃 2020-08-26 17:07

个回答

  • 代码_从入门到放弃
    2020-08-26 17:16:36

    const path = require('path');
    
    module.exports = {
        entry: './src/script/main.js',
        output: {
            path: path.resolve(__dirname, './dist/js'),
            filename: "bundle.js"
        },
        resolve:{
            alias:{
                '@':path.resolve(__dirname,'.')
            }
        },
    }

    这样写就好了