【问题标题】:How to watch specific files using webpack?如何使用 webpack 观看特定文件?
【发布时间】:2015-07-17 15:00:07
【问题描述】:
var webpack = require('webpack');

module.exports = {
    // devtool: 'source-map',
    // devtool: 'eval-source-map',
    debug: true,
    devServer: {
        contentBase: __dirname  +'/src/endpoint',
        colors: true,
        noInfo: true,
        host: '127.0.0.1',
        port: 8000,
        inline: true,
        hot: true,
        publicPath: '/static/'
    },
    context: __dirname + '/src',
    entry: {
        app: [
            'es6-shim',
            'reflect-metadata',
            './app/app'
        ]
    },
    output: {
        path: __dirname + '/src/endpoint/static',
        filename: '[name].js'
    },
    plugins: [
        new webpack.NoErrorsPlugin()
    ],
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: [
                    /node_modules/
                ],
                loader: 'babel',
                query: {
                    stage: 0
                }
            }
        ]
    }
};

这是我目前的设置。我不明白如何强制 webpack 监视特定文件?例如我想在任何匹配/\.html$/ 的文件更新时触发编译。

【问题讨论】:

  • 你是 requiring 的 html 模板,通过 html-loader 之类的东西吗?

标签: webpack webpack-dev-server


【解决方案1】:

您可能想尝试像webpack-service 这样的库。 Webpack 自己的 watcher 有时会有点受限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-21
    • 2016-01-16
    • 1970-01-01
    • 2014-01-01
    • 1970-01-01
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多