简体   繁体   中英

How to watch specific files using webpack?

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
                }
            }
        ]
    }
};

Here is my current setup. I don't understand how to force webpack watch specific files? eg I want to trigger compilation when any file matching /\\.html$/ is updated.

You might want to try out a library like webpack-service . Webpack's own watcher is a little limited sometimes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM