G
G
gevru2020-02-14 21:45:11
PHP
gevru, 2020-02-14 21:45:11

How to start webpack-dev-server with livereload frontend and php on backend?

There is a project on Svelte.js and php as a backend ... so things have already developed.
The project is built by webpack based on the default webpack svelte template provided.
PHP in the project is still static.

Everything is going well and even with livereload takes off, everything is fine.
Except that php won't start under webpack-dev-server.

PHP 7 is installed on the computer.
I suspect that either some additional package is needed, or the webpack-dev-server setting is needed.
But Google and Yandex still do not give an answer to the question of what is missing in my config, so that without iis and apache (and others like them) `npm run dev` would be enough to launch a project with php backend support and livereload on client.

resolve: {
        alias: {
            svelte: path.resolve('node_modules', 'svelte')
        },
        extensions: ['.mjs', '.js', '.svelte'],
        mainFields: ['svelte', 'browser', 'module', 'main']
    },
    output: {
        path: __dirname + '/public',
        filename: '[name].js',
        chunkFilename: '[name].[id].js'
    },
    module: {
        rules: [
            {
                test: /\.svelte$/,
                exclude: /node_modules/,
                use: {
                    loader: 'svelte-loader',
                    options: {
                        emitCss: true,
                        hotReload: true,
                        dev: true
                    }
                }
            },
            {
                test: /\.css$/,
                use: [
                    prod ? MiniCssExtractPlugin.loader : 'style-loader',
                    'css-loader'
                ]
            }
        ]
    },
    mode,
    plugins: [
        new MiniCssExtractPlugin({
            filename: '[name].css'
        })
    ],
    devtool: prod ? false: 'source-map'


It is known that starting from 5.4, a built-in server has appeared in php, which can be raised with the php -S localhost:8000 command.
However, I cannot somehow connect this in webpack and livereload

Share your bison experience.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SimBioT19, 2020-02-14
@SimBioT19

https://webpack.js.org/configuration/dev-server/#d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question