zoukankan      html  css  js  c++  java
  • 对webpack的初步研究3

    Output配置output配置选项告诉webpack如何将编译后的文件写入磁盘。请注意,虽然可以有多个entry点,但只output指定了一个配置。

    • filename to use for the output file(s).

    webpack.config.js

    module.exports = {
      output: {
        filename: 'bundle.js',
      }
    };
    

    This configuration would output a single bundle.js file into the dist directory.

    如果您的配置创建了多个“块”(与多个入口点一样或使用CommonsChunkPlugin等插件时),则应使用替换来确保每个文件都具有唯一名称。

    module.exports = {
      entry: {
        app: './src/app.js',
        search: './src/search.js'
      },
      output: {
        filename: '[name].js',
        path: __dirname + '/dist'
      }
    };
    
    // writes to disk: ./dist/app.js, ./dist/search.js

    高级 

    以下是使用CDN和资产哈希的更复杂的示例:

    config.js

    module.exports = {
      //...
      output: {
        path: '/home/proj/cdn/assets/[hash]',
        publicPath: 'http://cdn.example.com/assets/[hash]/'
      }
    };
    

    如果publicPath在编译时不知道输出文件的最终结果,则可以将其留空并在运行时通过__webpack_public_path__入口点文件中变量动态设置

    __webpack_public_path__ = myRuntimePublicPath;
    
    // rest of your application entry
  • 相关阅读:
    dell 服务器服务编码查询方法(Win & linux)
    English Voice of <<Wish You Were Here>>
    V3
    研究2张物理网卡 1台物理服务器 3个光猫 实现的离线下载服务器微架构 (3 光猫)
    注解
    单例模式
    线程同步锁
    线程实现的两种方式
    多线程简介
    Map接口
  • 原文地址:https://www.cnblogs.com/zhouyideboke/p/9645323.html
Copyright © 2011-2022 走看看