rykener / django-manifest-loader

Simplifies webpack configuration with Django
https://django-manifest-loader.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
104 stars 12 forks source link

document how to use with webpack-dev-server #49

Open devkral opened 3 years ago

devkral commented 3 years ago

For debugging it is better to have webpack-dev-server active. Sadly it is a bit tricky to configure: webpack.config.js

module.exports =  (env, options) =>({
 ...
  devServer: {
                              port: '8080'
 },
plugins: {

        new CleanWebpackPlugin({
            verbose: true,
//important elsewise minifest.json is deleted
            cleanOnceBeforeBuildPatterns: ['**/*', '!manifest.json'],
        }),
        new WebpackManifestPlugin({
            writeToFileEmit: true,
            publicPath: env['WEBPACK_SERVE'] ? 'http://localhost:8080/' : null,
        }),
})

it would be nice to include this trick in the documentation

My project uses this setup: https://github.com/devkral/secretgraph

devkral commented 3 years ago

there is a much nicer way:

module.exports =  (env, options) =>({
 ...
  devServer: {
                      port: '8080',
                      devMiddleware: {
                          writeToDisk: true,
                      },
                      headers: {
                          'Access-Control-Allow-Origin': '*'
                      },

 },
plugins: [

        new WebpackManifestPlugin({
            writeToFileEmit: true,
        }),
],
output: {
...
# replaces clean plugin
clean: true
}
}),