InjectByTag not working with interior comma, fix + some eslint fixes
This commit is contained in:
parent
ee443b5db9
commit
9e753447d3
12 changed files with 6440 additions and 18254 deletions
130
.eslintrc
130
.eslintrc
|
@ -1,27 +1,24 @@
|
||||||
{
|
{
|
||||||
"parser": "babel-eslint",
|
"parser": "babel-eslint",
|
||||||
"extends": "airbnb",
|
"extends": "airbnb",
|
||||||
|
"plugins": [
|
||||||
|
"jsdoc",
|
||||||
|
"import",
|
||||||
|
"filenames"
|
||||||
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"node": true,
|
"node": true,
|
||||||
"es6": true,
|
"es6": true
|
||||||
},
|
},
|
||||||
|
"parserOptions": {
|
||||||
"ecmaFeatures": {
|
"ecmaFeatures": {
|
||||||
"arrowFunctions": true,
|
"jsx": true
|
||||||
"blockBindings": true,
|
}
|
||||||
"classes": true,
|
|
||||||
"defaultParams": true,
|
|
||||||
"destructuring": true,
|
|
||||||
"jsx": true,
|
|
||||||
"modules": true,
|
|
||||||
"objectLiteralComputedProperties": true,
|
|
||||||
"objectLiteralShorthandMethods": true,
|
|
||||||
"objectLiteralShorthandProperties": true,
|
|
||||||
"spread": true,
|
|
||||||
"templateStrings": true
|
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
"__DEV__": true,
|
"__DEV__": true,
|
||||||
|
"test": true,
|
||||||
"describe": true,
|
"describe": true,
|
||||||
"it": true,
|
"it": true,
|
||||||
"beforeEach": true,
|
"beforeEach": true,
|
||||||
|
@ -30,44 +27,81 @@
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"by": true,
|
"by": true,
|
||||||
"element": true,
|
"element": true,
|
||||||
"jasmine": true
|
"jasmine": true,
|
||||||
|
"If": true,
|
||||||
|
"For": true,
|
||||||
|
"When": true,
|
||||||
|
"Choose": true,
|
||||||
|
"cy": true
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"jsdoc": {
|
||||||
|
"tagNamePreference": {
|
||||||
|
"param": "param",
|
||||||
|
"returns": "return"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"plugins": [
|
|
||||||
"react"
|
|
||||||
],
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unneeded-ternary" : "off",
|
"spaced-comment": "off",
|
||||||
|
"no-unused-expressions": "off",
|
||||||
|
"func-names": "off",
|
||||||
|
"new-parens": "off",
|
||||||
|
"no-continue": "off",
|
||||||
|
"one-var": ["error", "never"],
|
||||||
|
"class-methods-use-this": "off",
|
||||||
|
"no-restricted-syntax": "off",
|
||||||
|
"no-underscore-dangle": "off",
|
||||||
|
"consistent-return": "off",
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
"object-curly-spacing": ["error", "always", {
|
"guard-for-in": "off",
|
||||||
"objectsInObjects": false,
|
"no-param-reassign": "off",
|
||||||
"arraysInObjects": false
|
"arrow-body-style": "off",
|
||||||
|
"prefer-destructuring": "off",
|
||||||
|
"max-len": ["error", 140],
|
||||||
|
"no-unused-vars": ["error", { "vars": "all", "args": "none" }],
|
||||||
|
"arrow-parens": ["error", "always"],
|
||||||
|
"padded-blocks": "off",
|
||||||
|
"indent": ["error", 2, { "SwitchCase": 1 }],
|
||||||
|
"no-new": "off",
|
||||||
|
"new-cap": "off",
|
||||||
|
"function-paren-newline": "off",
|
||||||
|
"no-mixed-operators": "off",
|
||||||
|
"no-await-in-loop": "off",
|
||||||
|
"no-plusplus": "off",
|
||||||
|
"newline-per-chained-call": "off",
|
||||||
|
"no-restricted-globals": "off",
|
||||||
|
"object-curly-newline":"off",
|
||||||
|
"array-callback-return": "off",
|
||||||
|
|
||||||
|
"import/no-dynamic-require": "off",
|
||||||
|
"import/prefer-default-export": "off",
|
||||||
|
"import/first": "off",
|
||||||
|
"import/no-extraneous-dependencies": "off",
|
||||||
|
"import/extensions": "off",
|
||||||
|
"import/no-unresolved": "off",
|
||||||
|
"import/no-mutable-exports": "off",
|
||||||
|
"import/order": ["error", {
|
||||||
|
"groups": ["builtin", "external", "internal", "sibling", "parent", "index"],
|
||||||
|
"newlines-between": "always-and-inside-groups"
|
||||||
}],
|
}],
|
||||||
"comma-dangle": ["error", "never"],
|
|
||||||
"max-len": ["error", 100, 4, {"ignoreUrls": true}],
|
"jsdoc/check-param-names": 2,
|
||||||
"space-before-function-paren": ["error", "never"],
|
"jsdoc/check-tag-names": 2,
|
||||||
"no-multiple-empty-lines": ["error", {max: 1}],
|
"jsdoc/check-types": 2,
|
||||||
"no-use-before-define": 0,
|
"jsdoc/newline-after-description": 0,
|
||||||
"global-require": 0,
|
"jsdoc/require-description-complete-sentence": 0,
|
||||||
"no-else-return": "error",
|
"jsdoc/require-example": 0,
|
||||||
"no-param-reassign": 0,
|
"jsdoc/require-hyphen-before-param-description": 2,
|
||||||
"prefer-const": 0,
|
"jsdoc/require-param": 2,
|
||||||
"func-names": 0,
|
"jsdoc/require-param-description": 0,
|
||||||
"arrow-body-style": 0,
|
"jsdoc/require-param-name": 2,
|
||||||
"react/jsx-no-bind": [2, {
|
"jsdoc/require-param-type": 0,
|
||||||
"ignoreRefs": false,
|
"jsdoc/require-returns-description": 0,
|
||||||
"allowArrowFunctions": true,
|
"jsdoc/require-returns-type": 2,
|
||||||
"allowBind": true
|
|
||||||
}],
|
"filenames/match-regex": [2, "^(_){0,1}([a-zA-Z0-9])[0-9a-z-.]+$"],
|
||||||
"guard-for-in": 0,
|
"filenames/match-exported": [2, "kebab", "_" ],
|
||||||
"react/jsx-key": 2,
|
"filenames/no-index": "off"
|
||||||
"react/jsx-no-undef": 0,
|
|
||||||
"react/prefer-stateless-function": 0,
|
|
||||||
"react/jsx-closing-bracket-location": 0,
|
|
||||||
"no-undef": "error",
|
|
||||||
"one-var": 0,
|
|
||||||
"no-extra-semi": "error",
|
|
||||||
"semi": "error",
|
|
||||||
"prefer-arrow-callback": "error",
|
|
||||||
"new-cap": "off"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
README.md
10
README.md
|
@ -24,8 +24,6 @@ Auto Inject Version (AIV) can:
|
||||||
- auto increase package.json version by --env.major, --env.minor, --env.patch passed into webpack
|
- auto increase package.json version by --env.major, --env.minor, --env.patch passed into webpack
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# How to use
|
# How to use
|
||||||
It's easy to set it up, all you need is:
|
It's easy to set it up, all you need is:
|
||||||
* use WebpackAutoInject in webpack plugins
|
* use WebpackAutoInject in webpack plugins
|
||||||
|
@ -56,6 +54,8 @@ module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
new WebpackAutoInject({
|
new WebpackAutoInject({
|
||||||
NAME: 'AIV custom name',
|
NAME: 'AIV custom name',
|
||||||
|
// specify the name of the tag in the outputed files eg
|
||||||
|
// bundle.js: [SHORT] Version: 0.13.36 ...
|
||||||
SHORT: 'CUSTOM',
|
SHORT: 'CUSTOM',
|
||||||
SILENT: false,
|
SILENT: false,
|
||||||
PACKAGE_JSON_PATH: './package.json',
|
PACKAGE_JSON_PATH: './package.json',
|
||||||
|
@ -74,6 +74,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
InjectByTag: {
|
InjectByTag: {
|
||||||
fileRegex: /\.+/,
|
fileRegex: /\.+/,
|
||||||
|
// regexp to find [AIV] tag inside html, if you tag contains unallowed characters you can adjust the regex
|
||||||
|
// but also you can change [AIV] tag to anything you want
|
||||||
|
AIVTagRegexp: /(\[AIV])(([a-zA-Z{} ,:;!()_@\-"'\\\/])+)(\[\/AIV])/g,
|
||||||
dateFormat: 'h:MM:ss TT'
|
dateFormat: 'h:MM:ss TT'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -100,6 +103,9 @@ module.exports = {
|
||||||
<span>
|
<span>
|
||||||
[AIV]V:{version} Date:{date}[/AIV]
|
[AIV]V:{version} Date:{date}[/AIV]
|
||||||
</span>
|
</span>
|
||||||
|
<span>
|
||||||
|
[AIV]Version {version} , {date}[/AIV]
|
||||||
|
</span>
|
||||||
</body>
|
</body>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
3
demo/dist/index-bundle.js
vendored
3
demo/dist/index-bundle.js
vendored
|
@ -1,4 +1,3 @@
|
||||||
// [AIV] Version: 0.13.36 - Friday, August 25th, 2017, 1:56:17 PM
|
|
||||||
/******/ (function(modules) { // webpackBootstrap
|
/******/ (function(modules) { // webpackBootstrap
|
||||||
/******/ // The module cache
|
/******/ // The module cache
|
||||||
/******/ var installedModules = {};
|
/******/ var installedModules = {};
|
||||||
|
@ -88,7 +87,7 @@ test(myVariable);
|
||||||
/* 1 */
|
/* 1 */
|
||||||
/***/ (function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
module.exports = "<!DOCTYPE html><html lang=en><head><meta charset=UTF-8><title>Title</title></head><body><span>0.13.36</span> <span>Friday, August 25th, 2017, 1:56:17 PM</span> <span>0.13.36_Friday, August 25th, 2017, 1:56:17 PM</span> <span>V:0.13.36 Date:Friday, August 25th, 2017, 1:56:17 PM</span></body></html>"
|
module.exports = "<!DOCTYPE html><html lang=en><head><meta charset=UTF-8><title>Title</title></head><body><span>0.13.36</span> <span>7:54:43</span> <span>0.13.36_7:54:43</span> <span>V:0.13.36 Date:7:54:43</span> <span>Version 0.13.36 , 7:54:43</span></body></html>"
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 2 */
|
/* 2 */
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"html-loader": "^0.4.5",
|
"html-loader": "^0.4.5",
|
||||||
"html-minify-loader": "^1.1.0",
|
"html-minify-loader": "^1.1.0",
|
||||||
|
"nodemon": "^1.17.2",
|
||||||
"raw-loader": "^0.5.1",
|
"raw-loader": "^0.5.1",
|
||||||
"webpack": "^2.3.3",
|
"webpack": "^2.3.3",
|
||||||
"webpack-auto-inject-version": "^0.5.10"
|
"webpack-auto-inject-version": "^0.5.10"
|
||||||
|
|
|
@ -17,5 +17,8 @@
|
||||||
<span>
|
<span>
|
||||||
[AIV]V:{version} Date:{date}[/AIV]
|
[AIV]V:{version} Date:{date}[/AIV]
|
||||||
</span>
|
</span>
|
||||||
|
<span>
|
||||||
|
[AIV]Version {version} , {date}[/AIV]
|
||||||
|
</span>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,61 +1,63 @@
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// Require WebpackAutoInject from npm installed modules ( preferred )
|
// Require WebpackAutoInject from npm installed modules ( preferred )
|
||||||
// var WebpackAutoInject = require('webpack-auto-inject-version');
|
// var WebpackAutoInject = require('webpack-auto-inject-version');
|
||||||
// Require WebpackAutoInject from dist - dev purpose only ( do not use the below line )
|
// Require WebpackAutoInject from dist - dev purpose only ( do not use the below line )
|
||||||
var WebpackAutoInject = require('../dist/WebpackAutoInjectVersion');
|
const WebpackAutoInject = require('../dist/WebpackAutoInjectVersion');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
watch: true,
|
watch: true,
|
||||||
entry: {
|
entry: {
|
||||||
index: ['./src/main.js']
|
index: ['./src/main.js'],
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.html']
|
extensions: ['.js', '.html'],
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: '[name]-bundle.js',
|
filename: '[name]-bundle.js',
|
||||||
path: path.resolve(process.cwd(), 'dist')
|
path: path.resolve(process.cwd(), 'dist'),
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
include: [
|
include: [
|
||||||
path.resolve('src')
|
path.resolve('src'),
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.json$/,
|
test: /\.json$/,
|
||||||
loader: 'json-loader'
|
loader: 'json-loader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.txt$/,
|
test: /\.txt$/,
|
||||||
loader: 'raw-loader'
|
loader: 'raw-loader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.html$/,
|
test: /\.html$/,
|
||||||
loader: 'raw-loader!html-minify-loader'
|
loader: 'raw-loader!html-minify-loader',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new WebpackAutoInject({
|
new WebpackAutoInject({
|
||||||
components: {
|
components: {
|
||||||
AutoIncreaseVersion: true,
|
AutoIncreaseVersion: false,
|
||||||
InjectAsComment: true,
|
InjectAsComment: false,
|
||||||
InjectByTag: true
|
InjectByTag: true,
|
||||||
},
|
},
|
||||||
componentsOptions: {
|
componentsOptions: {
|
||||||
AutoIncreaseVersion: {
|
AutoIncreaseVersion: {
|
||||||
runInWatchMode: false // it will increase version with every single build!
|
runInWatchMode: false, // it will increase version with every single build!
|
||||||
},
|
},
|
||||||
InjectAsComment: {
|
InjectAsComment: {
|
||||||
tag: 'Version: {version} - {date}'
|
tag: 'Version: {version}, {date}',
|
||||||
},
|
},
|
||||||
InjectByTag: {
|
InjectByTag: {
|
||||||
fileRegex: /\.+/
|
fileRegex: /\.+/,
|
||||||
}
|
dateFormat: 'h:MM:ss',
|
||||||
}
|
},
|
||||||
})
|
},
|
||||||
]
|
}),
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
20182
dist/WebpackAutoInjectVersion.js
vendored
20182
dist/WebpackAutoInjectVersion.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,8 @@
|
||||||
"description": "Webpack plugin for auto inject version from package.json",
|
"description": "Webpack plugin for auto inject version from package.json",
|
||||||
"main": "dist/WebpackAutoInjectVersion.js",
|
"main": "dist/WebpackAutoInjectVersion.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "babel-node tools/compile.js"
|
"start": "babel-node tools/compile.js",
|
||||||
|
"eslint": "eslint ./src/**"
|
||||||
},
|
},
|
||||||
"author": "Radoslaw Swiat",
|
"author": "Radoslaw Swiat",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
@ -26,6 +27,9 @@
|
||||||
"eslint-config-airbnb": "^6.2.0",
|
"eslint-config-airbnb": "^6.2.0",
|
||||||
"eslint-loader": "^1.5.0",
|
"eslint-loader": "^1.5.0",
|
||||||
"eslint-plugin-babel": "^3.2.0",
|
"eslint-plugin-babel": "^3.2.0",
|
||||||
|
"eslint-plugin-filenames": "^1.2.0",
|
||||||
|
"eslint-plugin-import": "^2.9.0",
|
||||||
|
"eslint-plugin-jsdoc": "^3.5.0",
|
||||||
"eslint-plugin-jsx-control-statements": "^2.1.1",
|
"eslint-plugin-jsx-control-statements": "^2.1.1",
|
||||||
"eslint-plugin-react": "^4.2.3",
|
"eslint-plugin-react": "^4.2.3",
|
||||||
"gutil": "^1.6.4",
|
"gutil": "^1.6.4",
|
||||||
|
|
|
@ -10,7 +10,6 @@ import config from 'config';
|
||||||
export default class InjectByTag {
|
export default class InjectByTag {
|
||||||
|
|
||||||
static componentName = 'InjectByTag';
|
static componentName = 'InjectByTag';
|
||||||
static AIVTagRegexp = /(\[AIV])(([a-zA-Z{} :;!()_@\-"'\\\/])+)(\[\/AIV])/g;
|
|
||||||
|
|
||||||
constructor(context) {
|
constructor(context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -19,23 +18,23 @@ export default class InjectByTag {
|
||||||
/**
|
/**
|
||||||
* Apply will be called from main class
|
* Apply will be called from main class
|
||||||
* @protected
|
* @protected
|
||||||
* @returns {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
apply() {
|
apply() {
|
||||||
this.context.compiler.plugin('emit', (compilation, cb) => {
|
this.context.compiler.plugin('emit', (compilation, cb) => {
|
||||||
// for every output file
|
// for every output file
|
||||||
for (let basename in compilation.assets) {
|
for (const basename in compilation.assets) {
|
||||||
// only if match regex
|
// only if match regex
|
||||||
if (this.context.config.componentsOptions.InjectByTag.fileRegex.test(basename)) {
|
if (this.context.config.componentsOptions.InjectByTag.fileRegex.test(basename)) {
|
||||||
let replaced = 0;
|
let replaced = 0;
|
||||||
let asset = compilation.assets[basename];
|
const asset = compilation.assets[basename];
|
||||||
|
|
||||||
const originalSource = asset.source();
|
const originalSource = asset.source();
|
||||||
if (!originalSource || typeof originalSource.replace !== 'function') {
|
if (!originalSource || typeof originalSource.replace !== 'function') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let modFile = originalSource.replace(InjectByTag.AIVTagRegexp, (tag) => {
|
const modFile = originalSource.replace(this.context.config.componentsOptions.InjectByTag.AIVTagRegexp, (tag) => {
|
||||||
// handle version
|
// handle version
|
||||||
tag = tag.replace(/(\{)(version)(\})/g, () => {
|
tag = tag.replace(/(\{)(version)(\})/g, () => {
|
||||||
return this.context.version;
|
return this.context.version;
|
||||||
|
@ -54,11 +53,6 @@ export default class InjectByTag {
|
||||||
return tag;
|
return tag;
|
||||||
});
|
});
|
||||||
|
|
||||||
// let modFile = originalSource.replace(/(\[AIV\]{version}\[\/AIV\])/g, () => {
|
|
||||||
// replaced++;
|
|
||||||
// return this.context.version;
|
|
||||||
// });
|
|
||||||
|
|
||||||
asset.source = () => modFile;
|
asset.source = () => modFile;
|
||||||
log.info(`InjectByTag : match : ${basename} : replaced : ${replaced}`);
|
log.info(`InjectByTag : match : ${basename} : replaced : ${replaced}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,28 @@
|
||||||
export default {
|
export default {
|
||||||
NAME: 'Auto Inject Version',
|
NAME: 'Auto Inject Version CONFIG',
|
||||||
SHORT: 'AIV',
|
SHORT: 'AIV_SHORT',
|
||||||
SILENT: false,
|
SILENT: false,
|
||||||
PACKAGE_JSON_PATH: './package.json',
|
PACKAGE_JSON_PATH: './package.json',
|
||||||
components: {
|
components: {
|
||||||
AutoIncreaseVersion: true,
|
AutoIncreaseVersion: true,
|
||||||
InjectAsComment: true,
|
InjectAsComment: true,
|
||||||
InjectByTag: true
|
InjectByTag: true,
|
||||||
},
|
},
|
||||||
componentsOptions: {
|
componentsOptions: {
|
||||||
AutoIncreaseVersion: {
|
AutoIncreaseVersion: {
|
||||||
runInWatchMode: false
|
runInWatchMode: false,
|
||||||
},
|
},
|
||||||
InjectAsComment: {
|
InjectAsComment: {
|
||||||
tag: 'Build version: {version} - {date}',
|
tag: 'Build version: {version} - {date}',
|
||||||
dateFormat: 'dddd, mmmm dS, yyyy, h:MM:ss TT'
|
dateFormat: 'dddd, mmmm dS, yyyy, h:MM:ss TT',
|
||||||
},
|
},
|
||||||
InjectByTag: {
|
InjectByTag: {
|
||||||
fileRegex: /\.+/,
|
fileRegex: /\.+/,
|
||||||
dateFormat: 'dddd, mmmm dS, yyyy, h:MM:ss TT'
|
AIVTagRegexp: /(\[AIV])(([a-zA-Z{} ,:;!()_@\-"'\\\/])+)(\[\/AIV])/g,
|
||||||
}
|
dateFormat: 'dddd, mmmm dS, yyyy, h:MM:ss TT',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
LOGS_TEXT: {
|
LOGS_TEXT: {
|
||||||
AIS_START: 'Auto inject version started'
|
AIS_START: 'Auto inject version started',
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/* global define */
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import config from 'config';
|
import config from 'config';
|
||||||
import log from 'core/log';
|
import log from 'core/log';
|
||||||
import { merge, transform } from 'lodash';
|
import merge from 'lodash/merge';
|
||||||
|
import transform from 'lodash/transform';
|
||||||
|
|
||||||
// import sub components
|
// import sub components
|
||||||
import AutoIncreaseVersion from 'components/auto-increase-version/auto-increase-version';
|
import AutoIncreaseVersion from 'components/auto-increase-version/auto-increase-version';
|
||||||
|
@ -19,7 +20,7 @@ export default class WebpackAutoInject {
|
||||||
*/
|
*/
|
||||||
constructor(userConfig) {
|
constructor(userConfig) {
|
||||||
this.setConfig(userConfig);
|
this.setConfig(userConfig);
|
||||||
let packageFile = JSON.parse(
|
const packageFile = JSON.parse(
|
||||||
fs.readFileSync(path.resolve(this.config.PACKAGE_JSON_PATH), 'utf8')
|
fs.readFileSync(path.resolve(this.config.PACKAGE_JSON_PATH), 'utf8')
|
||||||
);
|
);
|
||||||
this.version = packageFile.version;
|
this.version = packageFile.version;
|
||||||
|
@ -35,7 +36,7 @@ export default class WebpackAutoInject {
|
||||||
*/
|
*/
|
||||||
setConfig(userConfig) {
|
setConfig(userConfig) {
|
||||||
this.config = merge(config, userConfig);
|
this.config = merge(config, userConfig);
|
||||||
|
console.log(this.config);
|
||||||
// lets convert all components names to lowercase - to prevent issues
|
// lets convert all components names to lowercase - to prevent issues
|
||||||
this.config.components = transform(this.config.components, (result, val, key) => {
|
this.config.components = transform(this.config.components, (result, val, key) => {
|
||||||
result[key.toLowerCase()] = val;
|
result[key.toLowerCase()] = val;
|
||||||
|
|
|
@ -4,12 +4,12 @@ export default {
|
||||||
target: 'node',
|
target: 'node',
|
||||||
entry: ['./src/main.js'],
|
entry: ['./src/main.js'],
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js']
|
extensions: ['.js'],
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: 'WebpackAutoInjectVersion.js',
|
filename: 'WebpackAutoInjectVersion.js',
|
||||||
path: path.resolve(process.cwd(), 'dist'),
|
path: path.resolve(process.cwd(), 'dist'),
|
||||||
libraryTarget: 'umd'
|
libraryTarget: 'umd',
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
|
@ -17,23 +17,22 @@ export default {
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
use: [
|
use: [
|
||||||
'babel-loader',
|
'babel-loader',
|
||||||
'eslint-loader'
|
|
||||||
],
|
],
|
||||||
include: [
|
include: [
|
||||||
path.resolve('src')
|
path.resolve('src'),
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.json$/,
|
test: /\.json$/,
|
||||||
loader: 'json-loader'
|
loader: 'json-loader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.txt$/,
|
test: /\.txt$/,
|
||||||
loader: 'raw-loader'
|
loader: 'raw-loader',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue