zoukankan      html  css  js  c++  java
  • webpac4k运行webpack .srcmain.js .distundle.js打包出错

    打包的命令格式:webpack 要打包的文件的路径  打包好的输出文件的路径

    运行webpack .srcmain.js .distundle.js

    提示错误,错误信息如下:

    WARNING in configuration
    The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each
    environment.
    You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

    ERROR in multi ./src/main.js ./dist/bundle.js
    Module not found: Error: Can't resolve '.distundle.js' in 'E:RepositoriesAliyun University1.webpack-study'
    @ multi ./src/main.js ./dist/bundle.js main[1]

     解决方法1:

    将上面webpack命令改为webpack ./src/main.js --output-filename ./dist/bundle.js --output-path . --mode development,解决

    • --output-filename:设置要打包的文件目录
    • --output-path:打包文件放置的文件目录
    • --mode:告诉程序,在当前目录,我是属于开发状态development

    解决方法2:

    在配置文件中,需要手动指定 入口 和 出口
    1 module.exports = {
    2      
    3     // 在配置文件中,需要手动指定 入口 和 出口
    4     entry:path.join(__dirname,'./src/main.js'),//入口,表示,要使用 webpack 打包哪个文件
    5     output:{//输出配置相关的配置
    6         path:path.join(__dirname,'./dist'),//指定 打包好的文件,输出到哪个目录中去
    7         filename:'bundle.js' //这是指定 输出的文件的名称
    8     }
    9 }

    打包的命令格式:webpack

    参考博客:https://www.cnblogs.com/murenziwei/p/10328813.html

  • 相关阅读:
    C#数组的使用
    CLR设计类型之接口
    CLR类型设计之泛型(二)
    CLR类型设计之泛型(一)
    CLR类型设计之属性
    CLR类型设计之参数传递
    CLR类型设计之方法与构造器
    将博客搬至CSDN
    Unity_与android交互
    CSS3制作hover下划线动画
  • 原文地址:https://www.cnblogs.com/songsongblue/p/11756216.html
Copyright © 2011-2022 走看看