Webpack学习 (三)

来源:互联网 发布:哈喽软件 编辑:程序博客网 时间:2024/06/10 09:45

7.webpack完整代码

var path = require('path');var htmlWebpackPlugin = require('html-webpack-plugin');var copyWebpackPlugin = require('copy-webpack-plugin');var cleanWebpackPlugin = require('clean-webpack-plugin');module.exports = {    entry: './app/index.js',    output: {        path: path.resolve(__dirname, 'build'),        filename: 'js/[name].js'    },    plugins: [        new htmlWebpackPlugin({            template: 'index.html',            filename: 'index.html',            inject: false,            minify: {                removeComments: true,                collapseWhitespace: false            }        }),        new copyWebpackPlugin([            { from: 'app/views/**' },            { from: 'app/resource/**' },            { from: 'app/images/**' }        ]),        new cleanWebpackPlugin(['build'], {        })    ],    module: {        loaders: [            {   //处理css格式的文件                test: /\.css$/,                  loader: 'style-loader!css-loader'            },            {   //处理各种图片格式的文件                test: /\.(png|jpg|gif|svg|eot|woff2|woff|ttf)$/i,                loader: "file-loader"            }        ]    }}
原创粉丝点击