Answer the question
In order to leave comments, you need to log in
Django conflict with React routing?
I did rerouting, but api is not taken because of it (it is sent to the main page)
The same with loading images
of the urls of the main application
urlpatterns = [
path('admin/', admin.site.urls),
path("api/<categoryId>/<page>/<amount>/", views.ProductListView.as_view(), name="api_post_list"),
path('', include('frontend.urls')),
path("items/api/id/<uid>/", views.SingleProductView.as_view(), name = "single_product_view")
]
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
urlpatterns = [
path('', views.index ),
re_path(r'^(?:.*)/?$', views.index ),
]
STATIC_URL = '/static/'
MEDIA_URL = "/images/"
MEDIA_ROOT = os.path.join(BASE_DIR, "frontend/static/frontend/images/")
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const isDev = process.env.NODE_ENV === 'development'
const isProd = !isDev
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, './static/frontend')
},
performance: {
hints: false
},
devtool: isDev ? 'source-map' : '',
plugins: [
new HtmlWebpackPlugin({
minify: {
collapseWhitespace: isProd
}
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, './src/favicon.ico'),
to: path.resolve(__dirname, './static/frontend')
}
],
}),
new MiniCssExtractPlugin({
filename: '[name].css'
})
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [{loader: 'babel-loader'}, isDev ? 'eslint-loader' : '']
},
{
test: /\.(jpg|png|svg)$/,
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
},
},
{
test: /\.sass$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hrm: isDev,
reloadAll: true
},
},
'css-loader', 'sass-loader'
]
},
{
test: /\.(ttf|woff|woff2|eot)$/,
use: ['file-loader']
}
]
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question