猿问

请教下webpack+node express的使用

在写组件的时候,会区分开发和生产环境,在webpack中使用插件html-webpack-plugin实现动态生成html文件,使用node 的express搭建一个服务器,webpack的代码如下:
生产环境下:

config.plugins = [    // 提取css为单文件
    new ExtractTextPlugin("../[name].[contenthash].css"),    new HtmlWebpackPlugin({
        filename: '../index.html',        template: path.resolve(__dirname, '../src/index.html'),
        inject: true
    })
];

开发环境下:

config.plugins = [

    new webpack.optimize.OccurenceOrderPlugin(),

    new webpack.HotModuleReplacementPlugin(),

    new webpack.NoErrorsPlugin(),

    new HtmlWebpackPlugin({

            filename: 'src/index.html',

            template: path.resolve(__dirname, '../src/index.html'),

            inject: true

        })

];

请教下: HtmlWebpackPlugin中的filename 为什么不是一样的,最后访问localhost:8080必须加上/src才能看到对应的页面,是什么原因??


杨__羊羊
浏览 740回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答