出口output

output 位于对象最顶级键(key),包括了一组选项,指示 webpack 如何去输出、以及在哪里输出你的「bundle、asset 和其他你所打包或使用 webpack 载入的任何内容」。

 

webpack.config.js文件

 

 module.exports = {

    mode: "none",

    context: __dirname + '/vueProject',

    // entry:'./test.js',

    entry: {

        a: './test.js'

    },

    output: {

        asyncChunks: true, //创建按需加载的异步 chunk。

       

        path:__dirname+"/dist2",//输出的目录,绝对路径,默认dist

       

        filename: 'bundle.js', //输出的文件名

        filename: '[name]-666-[id]bundle[hash:5].js', //输出的文件名,[hash:5]为5位哈希值,[id]为打包的chunk的id,[name]为入口的属性名,缺省则为mian,这几个一定记住 vue和react的css作用域-就是这个几个设计的

           

       

        library: 'hqyj',//库名

        library: {

            name: 'MyLibrary', //库名

            type: 'var', //配置将库暴露的方式。('var'、'module'、'assign'、'assign-properties'、'this'、'window'、'self'、'global'、'commonjs'、'commonjs2'、'commonjs-module'、'commonjs-static'、'amd'、'amd-require'、'umd'、'umd2'、'jsonp' 以及 'system')

        },

        libraryTarget: 'umd',//配置如何暴露 library,优先级比library高但是:[请使用 output.library.type 代理,因为我们可能在未来放弃对 output.libraryTarget 的支持。]

       

       

       

       

        auxiliaryComment: 'Test Comment', //各种模块化导出技术的统一注释(把type设置为umd)  

        //各种模块化导出技术的分别注释(webpack允许你的项目使用各种模块化技术 它都可以识别并打包)

        auxiliaryComment: {

            root: 'Root Comment',

            commonjs: 'CommonJS Comment',

            commonjs2: 'CommonJS2 Comment',

            amd: 'AMD Comment',

        },  

        clean: true, // 在生成文件之前清空 output 目录

        clean: {

              dry: true, // 小黑窗打印而不是删除应该移除的静态资源

            },

        clean: {

            keep: /ignored\/dir\//, // 保留 'ignored/dir' 下的静态资源不删

            // keep(asset) {

            //  return asset.includes('ignored/dir');//同上

            // },

        },      

    }

};

精彩文章

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: