Change Draftail import paths so code is properly split by Webpack

pull/4136/head
Thibaud Colas 2018-01-18 00:07:39 +02:00
rodzic 61a57b6691
commit db33741d25
3 zmienionych plików z 4 dodań i 10 usunięć

Wyświetl plik

@ -12,7 +12,6 @@ import Explorer, {
ExplorerToggle,
initExplorer,
} from './components/Explorer';
import draftail from './components/Draftail';
export {
Button,
@ -23,5 +22,4 @@ export {
Explorer,
ExplorerToggle,
initExplorer,
draftail,
};

Wyświetl plik

@ -6,18 +6,14 @@ const getEntryPath = (app, filename) => path.resolve('wagtail', app, 'static_src
// Generates a path to the output bundle to be loaded in the browser.
const getOutputPath = (app, filename) => path.join('wagtail', app, 'static', `wagtail${app}`, 'js', filename);
const isVendorModule = (module) => {
const res = module.resource;
return res && res.indexOf('node_modules') >= 0 && res.match(/\.js$/);
};
// Mapping from package name to exposed global variable.
const exposedDependencies = {
'focus-trap-react': 'FocusTrapReact',
'react': 'React',
'react-dom': 'ReactDOM',
'react-transition-group/CSSTransitionGroup': 'CSSTransitionGroup',
}
'draft-js': 'DraftJS',
};
module.exports = function exports() {
const entry = {
@ -41,7 +37,7 @@ module.exports = function exports() {
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: getOutputPath('admin', '[name].js'),
minChunks: isVendorModule,
minChunks: 2,
}),
],
resolve: {

Wyświetl plik

@ -1,4 +1,4 @@
import { draftail } from 'wagtail-client';
import draftail from '../../../../../client/src/components/Draftail';
// Expose as a global variable, for integration with other scripts.
window.draftail = draftail;