javascript - 求助关于webpack多页面的配置!
怪我咯
怪我咯 2017-04-11 11:30:45
0
5
387

网上大多是关于单页项目的配置教程,偶尔搜到一篇多页面配置的,又会加入一些乱七八糟的其他插件和功能把你弄晕,哪里有关于多页面的配置教程啊?就是普通网站开发的多页面,有index.html,servise.html,about.html,contact.html,等等。

怪我咯
怪我咯

走同样的路,发现不同的人生

répondre à tous(5)
洪涛

webpack 多页其实就是配置多个 entry 入口,然后建立对应的 html 模版

https://webpack.js.org/guides...

PHPzhong

如果只是几个页面,完全可以做成单页面应用,用路由和webpack做成按需加载,也是挺不错的

左手右手慢动作

我以前用过一个但是是很简单,多页面的。
/webpack.config.js/

var path = require('path');
module.exports = {
    entry:{
        main:'./src/main.js',
        list:'./src/list.js',
        subject:'./src/subject.js',
        more:'./src/more.js',
    },
    output:{
        path:path.resolve(__dirname,'build'),
        filename:'[name].bundle.js'
    },
    module:{
        loaders:[
            {
                test:/\.js[x]?$/,
                loader:'babel',
                query:{
                    presets:['react','es2015']
                }
            },
            {
                test:/\.css$/,
                loader:'style!css'
            },
            {
                test:/\.less$/,
                loader:'style!css!less'
            },
            {
                test:/\.(png|jpg|gif)$/,
                loader:'url?limit=8192'
            }
        ]
    },
    devServer:{
        historyApiFallback:true,
        hot:true,
        inline:true,
        progress:true,
        port:7070
    }
}

最后生成的文件目录!

Ty80

如果输出目录你可以接受在单一目录下的话配置多个entry入口是可以解决的,但是如果是你要求输出目录是多个目录的话可能需要结合gulp这些工具一起使用(ps:我是这样这样解决的)

阿神

今天刚好撸了一个脚手架 https://github.com/fe-config/...

应该是你要的

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!