Skip to content

Commit

Permalink
Merge pull request #4 from thetutlage/master
Browse files Browse the repository at this point in the history
Improvements to the setup process
  • Loading branch information
RomainLanz committed Jun 26, 2020
2 parents 10e1d2b + fb6166a commit ad6a1fc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
31 changes: 24 additions & 7 deletions instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,37 @@ import { ApplicationContract } from '@ioc:Adonis/Core/Application'
*/
export default async function instructions (
projectRoot: string,
_app: ApplicationContract,
_: ApplicationContract,
sink: typeof sinkStatic,
) {
const pkg = new sink.files.PackageJsonFile(projectRoot)
pkg.install('@symfony/webpack-encore', undefined, true)

/**
* Scripts to run encore
*/
pkg.appendScript('build:front', 'npx encore dev --watch')
pkg.appendScript('build:front:prod', 'NODE_ENV=production npx encore production')

const configPath = join(__dirname, 'templates', 'webpack.config.js')
const template = new sink.files.TemplateLiteralFile(projectRoot, 'webpack.config.js', configPath)
template.apply().commit()
sink.logger.create('webpack.config.js')
/**
* Copy webpack config file
*/
sink.utils.copyFiles(join(__dirname, 'templates'), projectRoot, ['webpack.config.js'])

/**
* Install required dependencies
*/
sink.logger.info('Installing "@symfony/webpack-encore" and "webpack-notifier"...')

sink.logger.info('Installing @symfony/webpack-encore')
pkg.install('@symfony/webpack-encore', undefined, true)
pkg.install('webpack-notifier', undefined, true)
await pkg.commitAsync()

sink.logger.success('Packages installed!')

/**
* Usage instructions
*/
console.log(' ')
console.log(` ${sink.colors.gray('$')} Run ${sink.colors.cyan('npm run build:front')} to start the build`)
console.log(` ${sink.colors.gray('$')} Run ${sink.colors.cyan('npm run build:front:prod')} to build for production`)
}
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"clean": "del build",
"commit": "git-cz",
"compile": "npm run lint && npm run clean && tsc",
"copyfiles": "copyfiles \"templates/**/*.js\" build",
"copyfiles": "copyfiles \"templates/**/*\" build",
"lint": "eslint . --ext=.ts",
"prepublishOnly": "npm run build",
"release": "np"
Expand Down Expand Up @@ -71,6 +71,19 @@
"instructions": "./build/instructions.js",
"providers": [
"@slynova/symfony-encore"
]
],
"templates": {
"basePath": "./build/templates",
"resources": [
{
"src": "app.css",
"dest": "css/app.css"
},
{
"src": "app.js",
"dest": "js/app.js"
}
]
}
}
}
4 changes: 4 additions & 0 deletions templates/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Write your CSS in this file
* Generated by: @slynova/symfony-encore
*/
4 changes: 4 additions & 0 deletions templates/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Write your Javascript in this file
* Generated by: @slynova/symfony-encore
*/

0 comments on commit ad6a1fc

Please sign in to comment.