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
  • 相关阅读:
    udev 禁止某些驱动自动加载
    AT91SAM9XEK ramdisk 启动笔记
    MTD 工具使用
    kmp问题
    野指针 空指针 通用指针
    manacher算法实现
    manacher算法
    strcpy和strlen
    冒泡排序
    C++的重载(overload)与重写(override
  • 原文地址:https://www.cnblogs.com/zhouyideboke/p/9645323.html
Copyright © 2011-2022 走看看