Convert cms/static/js/factories/asset_index.js to be bundled using webpack
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
* done.
|
||||
*/
|
||||
modules: getModulesList([
|
||||
'js/factories/asset_index',
|
||||
'js/factories/base',
|
||||
'js/factories/container',
|
||||
'js/factories/course_create_rerun',
|
||||
|
||||
7
cms/static/js/pages/asset_index.js
Normal file
7
cms/static/js/pages/asset_index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
define(
|
||||
['js/factories/asset_index', 'common/js/utils/page_factory'],
|
||||
function(AssetIndexFactory, invokePageFactory) {
|
||||
'use strict';
|
||||
invokePageFactory('AssetIndexFactory', AssetIndexFactory);
|
||||
}
|
||||
);
|
||||
@@ -27,16 +27,16 @@
|
||||
% endif
|
||||
</%block>
|
||||
|
||||
<%block name="requirejs">
|
||||
<%block name="page_bundle">
|
||||
% if not waffle_flag_enabled:
|
||||
require(["js/factories/asset_index"], function (AssetIndexFactory) {
|
||||
AssetIndexFactory({
|
||||
assetCallbackUrl: "${asset_callback_url|n, js_escaped_string}",
|
||||
uploadChunkSizeInMBs: ${chunk_size_in_mbs|n, dump_js_escaped_json},
|
||||
maxFileSizeInMBs: ${max_file_size_in_mbs|n, dump_js_escaped_json},
|
||||
maxFileSizeRedirectUrl: "${max_file_size_redirect_url|n, js_escaped_string}"
|
||||
});
|
||||
});
|
||||
<%static:invoke_page_bundle page_name="js/pages/asset_index" class_name="AssetIndexFactory">
|
||||
{
|
||||
assetCallbackUrl: "${asset_callback_url|n, js_escaped_string}",
|
||||
uploadChunkSizeInMBs: ${ chunk_size_in_mbs| n, dump_js_escaped_json },
|
||||
maxFileSizeInMBs: ${ max_file_size_in_mbs| n, dump_js_escaped_json },
|
||||
maxFileSizeRedirectUrl: "${max_file_size_redirect_url|n, js_escaped_string}"
|
||||
}
|
||||
</%static:invoke_page_bundle>
|
||||
% endif
|
||||
</%block>
|
||||
|
||||
|
||||
@@ -11,9 +11,21 @@ var namespacedRequireFiles = [
|
||||
path.resolve(__dirname, 'common/static/common/js/components/views/feedback_notification.js'),
|
||||
path.resolve(__dirname, 'common/static/common/js/components/views/feedback_prompt.js'),
|
||||
path.resolve(__dirname, 'common/static/common/js/components/views/feedback.js'),
|
||||
path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js'),
|
||||
path.resolve(__dirname, 'cms/static/js/views/paging.js'),
|
||||
path.resolve(__dirname, 'common/static/common/js/components/utils/view_utils.js')
|
||||
];
|
||||
|
||||
// These files are used by RequireJS as well, so we can't remove
|
||||
// the instances of "text!some/file.underscore" (which webpack currently
|
||||
// processes twice). So instead we have webpack dynamically remove the `text!` prefix
|
||||
// until we can remove RequireJS from the system.
|
||||
var filesWithTextBangUnderscore = [
|
||||
path.resolve(__dirname, 'cms/static/js/views/assets.js'),
|
||||
path.resolve(__dirname, 'cms/static/js/views/paging_header.js'),
|
||||
path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js')
|
||||
]
|
||||
|
||||
var defineHeader = /\(function ?\(define(, require)?\) ?\{/;
|
||||
var defineFooter = /\}\)\.call\(this, define \|\| RequireJS\.define(, require \|\| RequireJS\.require)?\);/;
|
||||
|
||||
@@ -25,6 +37,7 @@ module.exports = {
|
||||
Import: './cms/static/js/features/import/factories/import.js',
|
||||
CourseOrLibraryListing: './cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx',
|
||||
'js/pages/login': './cms/static/js/pages/login.js',
|
||||
'js/pages/asset_index': './cms/static/js/pages/asset_index.js',
|
||||
|
||||
// LMS
|
||||
SingleSupportForm: './lms/static/support/jsx/single_support_form.jsx',
|
||||
@@ -114,11 +127,26 @@ module.exports = {
|
||||
}
|
||||
)
|
||||
},
|
||||
{
|
||||
test: filesWithTextBangUnderscore,
|
||||
loader: StringReplace.replace(
|
||||
['babel-loader'],
|
||||
{
|
||||
replacements: [
|
||||
{
|
||||
pattern: /text!(.*\.underscore)/,
|
||||
replacement: function(match, p1) { return p1; }
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
},
|
||||
{
|
||||
test: /\.(js|jsx)$/,
|
||||
exclude: [
|
||||
/node_modules/,
|
||||
namespacedRequireFiles
|
||||
namespacedRequireFiles,
|
||||
filesWithTextBangUnderscore
|
||||
],
|
||||
use: 'babel-loader'
|
||||
},
|
||||
@@ -174,7 +202,8 @@ module.exports = {
|
||||
'node_modules',
|
||||
'common/static/js/vendor/',
|
||||
'cms/static',
|
||||
'common/static/js/src'
|
||||
'common/static/js/src',
|
||||
'common/static/js/vendor/jQuery-File-Upload/js/'
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user