mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-17 18:34:52 +03:00
Set publicPath in prod webpack config
This commit is contained in:
parent
7afad7484f
commit
ab78c56319
|
@ -13,7 +13,7 @@ module.exports = {
|
|||
path: path.resolve(__dirname, '../{{cookiecutter.project_slug}}/static/webpack_bundles/'),
|
||||
publicPath: '/static/webpack_bundles/',
|
||||
filename: 'js/[name]-[fullhash].js',
|
||||
chunkFilename: 'js/[name]-[hash].js'
|
||||
chunkFilename: 'js/[name]-[hash].js',
|
||||
},
|
||||
plugins: [
|
||||
new BundleTracker({filename: path.resolve(__dirname, '../webpack-stats.json')}),
|
||||
|
@ -45,11 +45,11 @@ module.exports = {
|
|||
},
|
||||
'sass-loader',
|
||||
],
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
modules: ['node_modules'],
|
||||
extensions: ['.js', '.jsx']
|
||||
extensions: ['.js', '.jsx'],
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,4 +17,4 @@ module.exports = merge(commonConfig, {
|
|||
hot: false,
|
||||
liveReload: true,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,8 +1,24 @@
|
|||
const { merge } = require('webpack-merge');
|
||||
const commonConfig = require('./common.config');
|
||||
|
||||
// This variable should mirror the one from config/settings/production.py
|
||||
{%- if cookiecutter.use_whitenoise == 'n' and cookiecutter.cloud_provider == 'AWS' %}
|
||||
const s3BucketName = process.env.DJANGO_AWS_STORAGE_BUCKET_NAME;
|
||||
const awsS3Domain = process.env.DJANGO_AWS_S3_CUSTOM_DOMAIN ?
|
||||
process.env.DJANGO_AWS_S3_CUSTOM_DOMAIN
|
||||
: `${s3BucketName}.s3.amazonaws.com`;
|
||||
const staticUrl = `https://${awsS3Domain}/static/`;
|
||||
{%- elif cookiecutter.use_whitenoise == 'n' and cookiecutter.cloud_provider == 'GCP' %}
|
||||
const staticUrl = `https://storage.googleapis.com/${process.env.DJANGO_GCP_STORAGE_BUCKET_NAME}/static/`;
|
||||
{%- else %}
|
||||
const staticUrl = '/static/';
|
||||
{%- endif %}
|
||||
|
||||
module.exports = merge(commonConfig, {
|
||||
mode: 'production',
|
||||
devtool: 'source-map',
|
||||
bail: true,
|
||||
})
|
||||
output: {
|
||||
publicPath: `${staticUrl}webpack_bundles/`,
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user