R
R
roovwhite2016-09-27 18:53:34
JavaScript
roovwhite, 2016-09-27 18:53:34

How to get the result of the webpack loader?

I use preprocess-loader to get paths to other files from files (//@include somefolder/main.js). The ['./chat'] contains an include to other files that contain the same includes.
But there is a need for webpack watch to track changes in all files. This does not work in the current implementation.
Tell me, please, how can I get the result of the loader in the form of a map or an array in order to use the data in the entry?

module.exports = {
    context: path.resolve(__dirname),
    entry: {
        chat: ['./chat']
    },

    output: {
        path: path.resolve(__dirname),
        filename: "[name].js"
    },

    watch: true,

    module: {
        loaders: [{
            test: /\.js$/,
            loader: 'preprocess'
        }]
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Medin K, 2016-09-28
@medin84

Maybe this is
https://seesparkbox.com/foundry/write_better_front...
https://gist.github.com/asimpson/e3d5d9c6ea8ab8a68...

Q
qtuz, 2016-10-31
@qtuz

In order for Webpack to track changes in all files, the loader needs to tell it what dependencies the current file being processed has. This is done through a call this.addDependency(absolute_path_to_file). If the loader does not do this, then getting the output of the loader will not help you. You can write your own loader that will parse the source code with a regular expression and add all files to the dependency. If you put this loader before calling preprocess-loader, then changes will be tracked in all files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question