Skip to content

Commit

Permalink
import injector again
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaslee119 authored and 李 立 committed Oct 17, 2017
1 parent 294588c commit b1d808b
Show file tree
Hide file tree
Showing 8 changed files with 3,363 additions and 505 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
test/assets
test/assetsCoreTest
test/coverage
test/coverage
.idea
jest_0
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = function loaderEntry(source) {
checkPath(options.srcPath, options.builtTemplatePath, this.resourcePath);
checkFunction(options.extractor, options.addScopeAttr);
checkFunction(options.addScopeAttr);
checkFunction(options.injector);
checkSource(source);

const buildOption = {
Expand All @@ -40,9 +41,11 @@ module.exports = function loaderEntry(source) {
builtTemplatePath: options.builtTemplatePath,
isCodeSplit: options.isCodeSplit,
extractor: options.extractor,
injector: options.injector,
addScopeAttr: options.addScopeAttr,
currentPagePath: this.resourcePath,
}
publicPath: this.options.output.publicPath || '',
};

return core(source, buildOption);
};
3 changes: 2 additions & 1 deletion lib/rewriteTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = async function rewriteTemplate(component) {
if (fsx.existsSync(templatePath)) {
try {
const template = fsx.readFileSync(templatePath, 'utf8');
const res = await buildOption.addScopeAttr(template, component);
let res = await buildOption.addScopeAttr(template, component);
if (component.pageFlag) res = buildOption.injector(res, component, buildOption);
fsx.ensureDirSync(path.resolve(buildOption.builtTemplatePath, component.dir));
fsx.writeFileSync(path.resolve(buildOption.builtTemplatePath, component.dir, `${component.base}`), res);
} catch (e) {
Expand Down
Loading

0 comments on commit b1d808b

Please sign in to comment.