Answer the question
In order to leave comments, you need to log in
How to set a dynamic path to a file during assembly?
There is a problem with the production assembly of js files (from react).
The task is to set the path to the script dynamically and set up the development environment for further work.
//Так все собирается в один файл
import { Users } from './Admin/Users';
//А так собирает в разные файлы
require.ensure([], function(require) { var Users = require('./Admin/Users'); }, 'users');
//При сборке require.ensure возникает проблема использовать элемент Users
//Как можно использовать его здесь?
<Route path="Users" component={Users}></Route>
//Скрипры на thml для разработки подключаю, но users.bundle не видит
<script src="static/bundle.js"></script>
<script src="static/users.bundle.js"></script>
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/', // здесь нужен аналог php функции include (dirname(__FILE__)."/../Users.js");
chunkFilename: '[name].bundle.js'
}
Answer the question
In order to leave comments, you need to log in
react-router supports this functionality out of the box - documentation and sample application
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question