Skip to content

Commit 3defe34

Browse files
committed
Добавлена возможность задавать кастомные названия конфигов
1 parent 17597c1 commit 3defe34

File tree

8 files changed

+42
-7
lines changed

8 files changed

+42
-7
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
/settings.json
3-
node_modules
3+
node_modules
4+
/package-lock.json
5+
/change-list

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
examples
1+
examples
2+
change-list

lib/defaultValues.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module.exports = {
22
assetDirectory: 'assets',
3-
webpackDirectory: ''
3+
webpackDirectory: '',
4+
devConfig: 'webpack.dev.js',
5+
prodConfig: 'webpack.prod.js'
46
}

lib/inquirer.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const inquirer = require('inquirer')
2+
const fs = require('fs')
3+
const {resolve} = require('path')
24
const values = require('./defaultValues')
35

46
module.exports = {
@@ -21,6 +23,34 @@ module.exports = {
2123
type: 'input',
2224
message: 'Enter the directory up to webpack relative to @app',
2325
default: values.webpackDirectory
26+
},
27+
{
28+
name: 'devConfig',
29+
type: 'input',
30+
message: 'Enter the name of the development configuration',
31+
default: values.devConfig,
32+
validate: function (filePath) {
33+
let fullPath = resolve(process.cwd(), filePath)
34+
try {
35+
return fs.lstatSync(fullPath).isFile() ? true : 'Is not a file'
36+
} catch (e) {
37+
return e.message
38+
}
39+
}
40+
},
41+
{
42+
name: 'prodConfig',
43+
type: 'input',
44+
message: 'Enter the name of the production configuration',
45+
default: values.prodConfig,
46+
validate: function (filePath) {
47+
let fullPath = resolve(process.cwd(), filePath)
48+
try {
49+
return fs.lstatSync(fullPath).isFile() ? true : 'Is not a file'
50+
} catch (e) {
51+
return e.message
52+
}
53+
}
2454
}
2555
])
2656
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yii2-webpack",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Webpack integration with Yii2",
55
"keywords": [
66
"yii2",

webpack.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let configuration = new config({
55
mode: 'development'
66
})
77
configuration
8-
.mergeTo(config.load('./webpack.dev.js'))
8+
.mergeTo(config.load(configuration.settings.devConfig))
99
.addHtmlPluginToEntries()
1010
.mergeTo({
1111
plugins: [

webpack.prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let configuration = new config({
44
mode: 'production'
55
})
66
configuration
7-
.mergeTo(config.load('./webpack.prod.js'))
7+
.mergeTo(config.load(configuration.settings.prodConfig))
88
.addHtmlPluginToEntries()
99
.mergeTo({
1010
plugins: [

0 commit comments

Comments
 (0)