Skip to content

Commit

Permalink
Normalize input CSS as index.scss, outputs as ipack.js and ipack.css! #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanelian committed Oct 20, 2017
1 parent 795ff52 commit 824fca5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ With **one compiler to rule them all**, you can save time :watch:, save precious

Out of the box, these files will be used as the entry points:

- `client/js/index.ts`, compiled to `wwwroot/js/packed.js`
- `client/js/index.ts`, compiled to `wwwroot/js/ipack.js`

- `client/css/index.scss`, compiled to `wwwroot/css/packed.css`
- `client/css/index.scss`, compiled to `wwwroot/css/ipack.css`

- The Sass language compiler service has been configured to enable `@import` from `node_modules`!

Expand Down
6 changes: 3 additions & 3 deletions bin/Compiler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions bin/PipeTo/Sass.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/Settings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"postcss-discard-comments": "4.0.0-rc.2",
"resolve": "1.4.0",
"through2": "2.0.3",
"ts-loader": "3.0.3",
"ts-loader": "3.0.4",
"typescript": "2.6.0-rc",
"uglify-js": "3.1.4",
"undertaker": "1.2.0",
Expand Down
6 changes: 3 additions & 3 deletions src/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class Compiler {
let config: webpack.Configuration = {
entry: this.settings.jsEntry,
output: {
filename: 'bundle.js',
filename: 'ipack.js',
path: this.settings.outputJsFolder
},
externals: this.settings.externals,
Expand Down Expand Up @@ -240,7 +240,7 @@ export class Compiler {
/**
* Pipes the CSS project entry point as a Vinyl object.
*/
getCssEntryVinyl() {
pipeCssEntryVinyl() {
let g = through2.obj();

fse.readFile(this.settings.cssEntry, 'utf8').then(contents => {
Expand Down Expand Up @@ -278,7 +278,7 @@ export class Compiler {
glog('Compiling CSS', chalk.cyan(cssEntry));
let sassImports = [this.settings.npmFolder];

return this.getCssEntryVinyl()
return this.pipeCssEntryVinyl()
.pipe(this.flags.map ? sourcemaps.init() : through2.obj())
.pipe(To.Sass(sassImports))
.on('error', PipeErrorHandler)
Expand Down
9 changes: 4 additions & 5 deletions src/PipeTo/Sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import * as through2 from 'through2';
import * as path from 'path';
import * as applySourceMap from 'vinyl-sourcemaps-apply';

function replaceExtension(path: string, newExt: string) {
return path.substr(0, path.lastIndexOf('.')) + newExt;
}

/**
* Creates a new build pipe that performs compilation against piped Sass file entry point.
* Allows including folder path for resolving @import.
Expand Down Expand Up @@ -50,8 +46,11 @@ export function Sass(includePaths: string[]) {
applySourceMap(chunk, smap);
}

let newPath = path.join(path.dirname(chunk.path), 'ipack.css');
// E:\VS\TAM.Passport\TAM.Passport\client\css\site.scss --> E:\VS\TAM.Passport\TAM.Passport\client\css\ipack.css

chunk.contents = result.css;
chunk.path = replaceExtension(chunk.path, '.css');
chunk.path = newPath;

next(null, chunk);
});
Expand Down
6 changes: 3 additions & 3 deletions src/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ export class Settings {
}

/**
* Gets the full path to the index.ts entry point.
* Gets the full path to the TypeScript project entry point.
*/
get jsEntry(): string {
return path.join(this.inputJsFolder, 'index.ts');
}

/**
* Gets the full path to the site.scss entry point.
* Gets the full path to the Sass project entry point.
*/
get cssEntry(): string {
return path.join(this.inputCssFolder, 'site.scss');
return path.join(this.inputCssFolder, 'index.scss');
}

/**
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,8 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0"

electron-to-chromium@^1.3.24:
version "1.3.26"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.26.tgz#996427294861a74d9c7c82b9260ea301e8c02d66"
version "1.3.27"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz#78ecb8a399066187bb374eede35d9c70565a803d"

elliptic@^6.0.0:
version "6.4.0"
Expand Down Expand Up @@ -3052,9 +3052,9 @@ trim-newlines@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"

[email protected].3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-3.0.3.tgz#2b25865c220529093f40c997e81197444955e652"
[email protected].4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-3.0.4.tgz#5cc2f973fd8ea538ba96e0d7ad317e4e48b98ae8"
dependencies:
chalk "^2.0.1"
enhanced-resolve "^3.0.0"
Expand Down

0 comments on commit 824fca5

Please sign in to comment.