Skip to content

Commit

Permalink
Merge pull request #3 from tehpsalmist/windows
Browse files Browse the repository at this point in the history
Windows Compatibility
  • Loading branch information
tehpsalmist authored Jun 20, 2018
2 parents 0f01827 + d926b6d commit 2d3631e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

const program = require('commander')
const path = require('path')
const watch = require('./lib/watch')
const build = require('./lib/build')
const scripts = require('./lib/scripts')
Expand Down Expand Up @@ -32,16 +33,16 @@ program
.option('-d, --default', 'overwrites ng-tailwind.js file to default paths except any concurrent arguments')
.action((args) => {
const ngTwConfig = {}
if (args.config) ngTwConfig.configJS = args.config
if (args.source) ngTwConfig.sourceCSS = args.source
if (args.output) ngTwConfig.outputCSS = args.output
if (args.config) ngTwConfig.configJS = path.resolve(args.config)
if (args.source) ngTwConfig.sourceCSS = path.resolve(args.source)
if (args.output) ngTwConfig.outputCSS = path.resolve(args.output)
configure(ngTwConfig, args.default)
})

program
.command('scripts')
.alias('s')
.description('Automatically inserts ng-tailwindcss the default scripts into your package.json')
.description('Automatically inserts the default build/serve/watch scripts into your package.json')
.action((cmd) => {
scripts()
})
Expand Down
4 changes: 2 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module.exports = () => {
if (fs.existsSync(ngTwFile)) {
const config = require(ngTwFile)
exec(
`./node_modules/.bin/tailwind build ${config.sourceCSS} -c ${config.configJS} -o ${config.outputCSS}`,
`${path.resolve('./node_modules/.bin/tailwind')} build ${config.sourceCSS} -c ${config.configJS} -o ${config.outputCSS}`,
err => err ? console.error(err) : console.info('Successful Build!')
)
} else {
console.error('No ng-tailwind.js file exists.\nPlease run `ng-tailwindcss configure`.\nRun `ng-tailwindcss --help` for assistance,\nor view the Readme at\nhttps://github.com/tehpsalmist/ng-tailwindcss')
console.error('No ng-tailwind.js file exists.\nPlease run `ng-tailwindcss configure`.\n\nRun `ng-tailwindcss --help` for assistance,\nor view the Readme at\nhttps://github.com/tehpsalmist/ng-tailwindcss')
}
}
18 changes: 9 additions & 9 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const path = require('path')
module.exports = (userDefConfig, defaultOverride) => {
const ngTwFile = path.resolve(process.cwd(), 'ng-tailwind.js')
const defaultConfig = {
configJS: './tailwind.js',
sourceCSS: './src/tailwind.css',
outputCSS: './src/styles.css'
configJS: `${path.resolve('./tailwind.js')}`,
sourceCSS: `${path.resolve('./src/tailwind.css')}`,
outputCSS: `${path.resolve('./src/styles.css')}`
}
let newConfig
let currentConfig
Expand All @@ -22,8 +22,8 @@ module.exports = (userDefConfig, defaultOverride) => {
configJS: '${newConfig.configJS}',
sourceCSS: '${newConfig.sourceCSS}',
outputCSS: '${newConfig.outputCSS}'
}
`, err => {
}`,
err => {
if (err) console.error('Error updating ng-tailwind.js:', err)
}
)
Expand All @@ -39,8 +39,8 @@ module.exports = (userDefConfig, defaultOverride) => {
configJS: '${newConfig.configJS}',
sourceCSS: '${newConfig.sourceCSS}',
outputCSS: '${newConfig.outputCSS}'
}
`, err => {
}`,
err => {
if (err) console.error('Error updating ng-tailwind.js:', err)
}
)
Expand All @@ -55,8 +55,8 @@ module.exports = (userDefConfig, defaultOverride) => {
configJS: '${newConfig.configJS}',
sourceCSS: '${newConfig.sourceCSS}',
outputCSS: '${newConfig.outputCSS}'
}
`, err => {
}`,
err => {
if (err) console.error('Error creating ng-tailwind.js:', err)
}
)
Expand Down
2 changes: 1 addition & 1 deletion lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ module.exports = () => {
build()
})
} else {
console.error('No ng-tailwind.js file exists.\nPlease run `ng-tailwindcss configure`.\nRun `ng-tailwindcss --help` for assistance,\nor view the Readme at\nhttps://github.com/tehpsalmist/ng-tailwindcss')
console.error('No ng-tailwind.js file exists.\nPlease run `ng-tailwindcss configure` in your project\'s root directory.\nRun `ng-tailwindcss --help` for assistance,\nor view the Readme at https://github.com/tehpsalmist/ng-tailwindcss')
}
}
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you haven't used [Tailwind CSS](https://tailwindcss.com) yet, you really shou

You use `ng eject`! _(loud booing ensues)_

Yes, using this excellent [SO answer](https://stackoverflow.com/questions/47381149/angular-4-tailwindcss-setup/#answer-47502171) or [YouTube video](https://www.youtube.com/watch?v=mUS0gclgO9Q), you can get at the postCSS controls and have a smooth tailwind build process and enjoy faster development speeds _when writing your styles_. But when you need a fancy new component and you type `ng g c complicated-but-awesome`, you'll quickly realize you just lost 5-10 minutes of your life when your terminal barks back,
Yes, using this excellent [SO answer](https://stackoverflow.com/questions/47381149/angular-4-tailwindcss-setup/#answer-47502171) or [YouTube video](https://www.youtube.com/watch?v=mUS0gclgO9Q), you can get at the postCSS controls and have a smooth tailwind build process and enjoy faster development speeds _when writing your styles_. But when you need a fancy new component and you type `ng g c fancy-new-component`, you'll quickly realize you just lost 5-10 minutes of your life when your terminal barks back,

```
You're on your own, pal.
Expand Down Expand Up @@ -51,9 +51,9 @@ Put all your [tailwind imports](https://tailwindcss.com/docs/installation/#3-use
`ng new angular-meets-tailwind`

3. Follow Steps 1-3 from the Tailwind Installation Instructions:
- [Install Tailwind](https://tailwindcss.com/docs/installation#1-install-tailwind-via-npm) (`npm i tailwindcss -D`)
- [initialize](https://tailwindcss.com/docs/installation#2-create-a-tailwind-config-file) (`./node_modules/.bin/tailwind init`)
- [Use tailwind in your _source_ css files](https://tailwindcss.com/docs/installation#3-use-tailwind-in-your-css).
- [Install Tailwind](https://tailwindcss.com/docs/installation#1-install-tailwind-via-npm) (`npm i tailwindcss -D`)
- [initialize](https://tailwindcss.com/docs/installation#2-create-a-tailwind-config-file) (`./node_modules/.bin/tailwind init`)
- [Use tailwind in your _source_ css files](https://tailwindcss.com/docs/installation#3-use-tailwind-in-your-css).

A recommendation for new projects (no changes to global stylesheet yet) is to `touch src/tailwind.css` and use that file for all global styles and [component classes](https://tailwindcss.com/docs/extracting-components). See Configuration below for existing projects.

Expand Down

0 comments on commit 2d3631e

Please sign in to comment.