-
Notifications
You must be signed in to change notification settings - Fork 2
/
instructions.ts
49 lines (41 loc) · 2.11 KB
/
instructions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* eslint-disable max-len */
import * as sinkStatic from '@adonisjs/sink'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import { join } from 'path'
/**
* Instructions to be executed when setting up the package.
*/
export default async function instructions (
projectRoot: string,
_: ApplicationContract,
sink: typeof sinkStatic,
) {
const pkg = new sink.files.PackageJsonFile(projectRoot)
/**
* Scripts to run encore
*/
pkg.appendScript('mix:dev', 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js')
pkg.appendScript('mix:watch', 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js -- --watch')
pkg.appendScript('mix:hot', 'cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js')
pkg.appendScript('mix:prod', 'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js')
/**
* Copy webpack config file
*/
sink.utils.copyFiles(join(__dirname, 'templates'), projectRoot, ['webpack.mix.js'])
/**
* Install required dependencies
*/
sink.logger.info('Installing "laravel-mix" and "cross-env"...')
pkg.install('laravel-mix', undefined, true)
pkg.install('cross-env', 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 mix:dev')} to start the build`)
console.log(` ${sink.colors.gray('$')} Run ${sink.colors.cyan('npm run mix:watch')} to start the build and watch for changes`)
console.log(` ${sink.colors.gray('$')} Run ${sink.colors.cyan('npm run mix:hot')} to start the build with hot reload`)
console.log(` ${sink.colors.gray('$')} Run ${sink.colors.cyan('npm run mix:prod')} to build for production`)
}