Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kus-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
kus-admin
Commits
710b7196
Commit
710b7196
authored
Jan 23, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3/4
parent
c207cb35
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
12 deletions
+25
-12
index.js
index.js
+19
-7
require.js
public/controller/require.js
+4
-3
pcg-dom-util.js
public/js/pcg-dom-util.js
+1
-1
main.jsx
src/main.jsx
+1
-1
No files found.
index.js
View file @
710b7196
...
...
@@ -24,7 +24,7 @@ var cache = {};
const
serveBundle
=
async
function
(
tpl
,
res
){
var
fileName
=
dir
(
pack
.
src
,
pack
.
entry
.
js
);
var
posixName
=
pa
th
.
posix
.
join
(
pack
.
src
,
pack
.
entry
.
js
);
var
posixName
=
pa
ck
.
entry
.
js
;
//path.posix.join(pack.src,
);
console
.
log
(
fileName
)
fs
.
readFile
(
fileName
,
function
(
err
,
jsx
)
{
if
(
err
){
...
...
@@ -37,7 +37,7 @@ const serveBundle = async function(tpl, res){
'<script src="'
+
cacheEntry
+
'"></script>'
)
);
transformJSX
(
jsx
+
''
,
pa
th
.
posix
.
join
(
pack
.
src
,
pack
.
entry
.
js
)
,
function
(
err
,
result
)
{
transformJSX
(
jsx
+
''
,
pa
ck
.
entry
.
js
,
function
(
err
,
result
)
{
if
(
err
){
console
.
error
(
err
)
cache
[
'/'
+
cacheEntry
]
=
JSON
.
stringify
(
err
,
null
,
2
);
...
...
@@ -99,12 +99,13 @@ var transformServe = function(dir) {
if
(
req
.
url
.
substr
(
-
5
)
===
'.scss'
)
{
// not secure
fs
.
readFile
(
path
.
join
(
__dirname
,
req
.
url
),
function
(
err
,
data
){
console
.
log
(
'scss'
,
dir
,
req
.
url
,
__dirname
)
fs
.
readFile
(
path
.
join
(
__dirname
,
dir
,
req
.
url
),
function
(
err
,
data
){
if
(
err
){
next
();
}
else
{
sass
.
render
({
file
:
path
.
join
(
__dirname
,
req
.
url
),
file
:
path
.
join
(
__dirname
,
dir
,
req
.
url
),
sourceMap
:
true
,
importer
:
function
(
url
,
prev
,
done
)
{
console
.
log
(
url
,
prev
,
done
)
...
...
@@ -113,12 +114,15 @@ var transformServe = function(dir) {
// done is an optional callback, either consume it or return value synchronously.
// this.options contains this options hash
setTimeout
(
function
(
result
){
var
name
=
path
.
resolve
(
path
.
dirname
(
prev
),
url
)
var
name
=
path
.
resolve
(
path
.
dirname
(
prev
),
url
);
var
displayName
=
path
.
relative
(
path
.
join
(
__dirname
,
dir
),
path
.
resolve
(
path
.
dirname
(
prev
),
url
))
done
({
file
:
n
ame
,
// only one of them is required, see section Special Behaviours.
file
:
displayN
ame
,
// only one of them is required, see section Special Behaviours.
contents
:
fs
.
readFileSync
(
name
)
+
''
});
console
.
log
({
name
,
__dirname
,
dir
,
url
,
prev
})
},
10
);
// OR
//var result = someSyncFunction(url, prev);
...
...
@@ -136,17 +140,24 @@ var transformServe = function(dir) {
}
});
}
else
if
(
req
.
url
.
substr
(
-
4
)
===
'.jsx'
)
{
console
.
log
(
'Serve jsx'
,
dir
,
req
.
url
)
fs
.
readFile
(
path
.
join
(
dir
,
req
.
url
),
function
(
err
,
data
){
if
(
err
){
console
.
log
(
'No jsx'
,
err
)
next
();
}
else
{
console
.
log
(
'Transform jsx'
,
req
.
url
);
transformJSX
(
data
+
''
,
req
.
url
,
function
(
err
,
result
)
{
if
(
err
){
console
.
log
(
'Error in transforming jsx'
,
err
);
res
.
end
(
err
.
message
+
'
\
n'
+
err
.
stack
)
}
else
{
cache
[
req
.
url
+
'.map'
]
=
JSON
.
stringify
(
result
.
map
);
res
.
set
(
'SourceMap'
,
req
.
url
+
'.map'
);
res
.
end
(
result
.
code
)
res
.
end
(
result
.
code
);
debugger
;
}
})
}
...
...
@@ -159,6 +170,7 @@ var transformServe = function(dir) {
};
app
.
use
(
transformServe
(
'public'
));
app
.
use
(
transformServe
(
'src'
));
var
lives
=
[];
app
.
use
(
'/'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
req
.
originalUrl
)
...
...
public/controller/require.js
View file @
710b7196
...
...
@@ -125,10 +125,10 @@
}
};
var
log
=
function
()
{
var
log
=
console
.
log
;
/*
var log = function() {
console.log.apply(console, ['Define'].concat([].slice.call(arguments)));
};
};
*/
var
head
=
document
.
getElementsByTagName
(
'head'
)[
0
];
var
cssLoader
=
function
(
fileName
)
{
...
...
@@ -137,6 +137,7 @@
link
.
setAttribute
(
'type'
,
'text/css'
);
link
.
setAttribute
(
'href'
,
fileName
);
head
.
appendChild
(
link
);
return
true
;
};
var
jsLoader
=
function
(
fileName
)
{
fileName
=
fileName
.
replace
(
/src
\/
/
,
''
);
...
...
public/js/pcg-dom-util.js
View file @
710b7196
...
...
@@ -233,7 +233,7 @@
// ES 6 consts are not in global scope. So we can not just add vars to window
var
pointer
=
first
?
new
Function
(
'g'
,
'return typeof '
+
first
+
' !== "undefined"?'
+
first
+
':(glob["'
+
first
+
'"] = {})'
)(
glob
)
new
Function
(
'g
lob
'
,
'return typeof '
+
first
+
' !== "undefined"?'
+
first
+
':(glob["'
+
first
+
'"] = {})'
)(
glob
)
:
glob
;
tokens
.
reduce
(
function
(
pointer
,
token
,
i
,
full
)
{
...
...
src/main.jsx
View file @
710b7196
data
=
null
;
import
'./main.scss'
;
import
{
Button
}
from
'
.
/view/cmp/button.jsx'
import
{
Button
}
from
'/view/cmp/button.jsx'
export
default
function
()
{
let
tagField
,
exportEl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment