Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? e.g. I want to trigger compilation when any file matching /\.html$/ is updated.

like image 259
Gajus Avatar asked Nov 10 '22 09:11

Gajus


1 Answers

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

like image 194
Juho Vepsäläinen Avatar answered Dec 23 '22 05:12

Juho Vepsäläinen