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

  • 相关阅读:
    泛型的运用
    LinkdList和ArrayList异同、实现自定义栈
    MD5文件去重
    mysql协议解析
    solrconfig.xml主要配置项
    自定义特性使用
    使用OWIN 为WebAPI 宿主 跨平台
    Web.config配置文件详解
    IIS 之 在IIS7、IIS7.5中应用程序池最优配置方案
    GitHub 创建工程
  • 原文地址:https://www.cnblogs.com/songsongblue/p/11756216.html
Copyright © 2011-2022 走看看