Skip to content

Commit

Permalink
fix: remove node_module seperate transform, instead use js/css with p…
Browse files Browse the repository at this point in the history
…ath resolver
  • Loading branch information
hutchgrant committed Nov 5, 2020
1 parent a9b4788 commit 6fdf53d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 47 deletions.
2 changes: 0 additions & 2 deletions packages/cli/src/lifecycles/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const MarkdownTransform = require('../transforms/transform.md');
const CSSTransform = require('../transforms/transform.css');
const JSTransform = require('../transforms/transform.js');
const JSONTransform = require('../transforms/transform.json.js');
const NodeTransform = require('../transforms/transform.node');
const AssetTransform = require('../transforms/transform.assets');

function getDevServer(compilation) {
Expand All @@ -34,7 +33,6 @@ function getDevServer(compilation) {
new HTMLTransform(request, compilation),
new MarkdownTransform(request, compilation),
new CSSTransform(request, compilation),
new NodeTransform(request, compilation),
new JSTransform(request, compilation),
new JSONTransform(request, compilation),
new AssetTransform(request, compilation)
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/transforms/transform.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CSSTransform extends TransformInterface {
const cssPath = url.indexOf('/node_modules') >= 0
? path.join(process.cwd(), url)
: path.join(this.workspace, url);

const css = await fsp.readFile(cssPath, 'utf-8');
let body = '', contentType = '';

Expand Down
8 changes: 5 additions & 3 deletions packages/cli/src/transforms/transform.js.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ class JSTransform extends TransformInterface {
shouldTransform() {
const { url } = this.request;

return this.extensions.indexOf(path.extname(url)) >= 0 &&
url.indexOf('/node_modules') < 0 && url.indexOf('.json') < 0;
return this.extensions.indexOf(path.extname(url)) >= 0 && url.indexOf('.json') < 0;
}

async applyTransform() {
return new Promise(async (resolve, reject) => {
try {
const { url } = this.request;
const jsPath = url.indexOf('/node_modules') >= 0
? path.join(process.cwd(), url)
: path.join(this.workspace, this.request.url);

const jsPath = path.join(this.workspace, this.request.url);
const body = await fsp.readFile(jsPath, 'utf-8');
resolve({
body,
Expand Down
37 changes: 0 additions & 37 deletions packages/cli/src/transforms/transform.node.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/cli/src/transforms/transform.tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const getAppTemplateScripts = async (contents, userWorkspace) => {
const headLinks = root.querySelectorAll('head link');

appTemplateContents = appTemplateContents.replace(/<page-outlet><\/page-outlet>/, body);

headScripts.forEach(script => {
if (script.rawAttrs !== '') {
appTemplateContents = appTemplateContents.replace(/<\/script>/, `
Expand Down Expand Up @@ -169,7 +168,6 @@ const getMetaContent = (url, config, contents) => {
contents = contents.replace(/<title>(.*)<\/title>/, '');
contents = contents.replace('<head>', `<head><title>${title}</title>`);
contents = contents.replace('<meta-outlet></meta-outlet>', metaContent);
// console.log(contents);

return contents;
};
Expand Down
6 changes: 3 additions & 3 deletions www/components/header/header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css, html, LitElement, unsafeCSS } from 'lit-element';
// import client from '@greenwood/cli/data/client';
// import MenuQuery from '@greenwood/cli/data/queries/menu';
// import '@evergreen-wc/eve-container';
import '@evergreen-wc/eve-container';
import headerCss from './header.css';
// TODO import evergreenLogo from '../../assets/evergreen.svg';
import '../social-icons/social-icons.js';
Expand Down Expand Up @@ -51,7 +51,7 @@ class HeaderComponent extends LitElement {
const { navigation } = this;
return html`
<header class="header">
<!-- <eve-container fluid> -->
<eve-container fluid>
<div class="head-wrap">
<div class="brand">
Expand All @@ -77,7 +77,7 @@ class HeaderComponent extends LitElement {
<app-social-icons></app-social-icons>
</div>
<!-- </eve-container> -->
</eve-container>
</header>
`;
/* eslint-enable */
Expand Down

0 comments on commit 6fdf53d

Please sign in to comment.