finalize new version, 1.1.0

This commit is contained in:
rswiat 2018-03-15 11:07:22 +00:00
parent 318b16545c
commit e9889e6550
22 changed files with 1011 additions and 1934 deletions

View File

@ -1,20 +1,12 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
# Change these settings to your own preference
indent_style = space
indent_size = 2
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
charset=utf-8
end_of_line=lf
insert_final_newline=false
indent_style=space
indent_size=2
max_line_length = 140
wrap_width = 140
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
trim_trailing_whitespace = true

View File

@ -1,3 +1,4 @@
npm-debug*
.idea/
demo/
demo/
scrapyard/

View File

@ -12,10 +12,9 @@ $ npm install webpack-auto-inject-version --save-dev
[How to use](#user-content-how-to-use) <br>
[Available options](#user-content-available-options) <br>
[Output examples](#user-content-output-examples)
[How to use with other webpack plugins](#user-content-how-to-use-with-other-webpack-plugins)
[Change log](#user-content-change-log)
# What it does
Auto Inject Version (AIV) can:
- inject version from package.json into every bundle file as a comment ( at the top )
@ -23,7 +22,6 @@ Auto Inject Version (AIV) can:
- inject version from package.json into any place in CSS/JS file by special tag `[AIV]{version}[/AIV]`
- auto increase package.json version by --env.major, --env.minor, --env.patch passed into webpack
# How to use
It's easy to set it up, all you need is:
* use WebpackAutoInject in webpack plugins
@ -53,7 +51,6 @@ module.exports = {
...
plugins: [
new WebpackAutoInject({
NAME: 'AIV custom name',
// specify the name of the tag in the outputed files eg
// bundle.js: [SHORT] Version: 0.13.36 ...
SHORT: 'CUSTOM',
@ -201,9 +198,53 @@ Example html:
<html lang="en">
```
# How to use with other webpack plugins
Webpack plugins order matters!
Always try to put WebpackAutoInject as a first webpack plugin.
## compression-webpack-plugin
```
plugins: [
new WebpackAutoInject(),
new CompressionPlugin(),
]
```
## uglifyjs-webpack-plugin
```
plugins: [
new WebpackAutoInject(),
new UglifyJsPlugin(),
]
```
## webpack.optimize.UglifyJsPlugin
If the order won't be enough, you can always add ignore to the uglifyJsPlugin
to prevent stripping out AIV comments eg:
```
new webpack.optimize.UglifyJsPlugin({
...
output: {
// prevent version info to be removed from bundle.js
comments: /\[AIV\]/,
},
...
});
```
# Change log
## [1.1.0] - 15/03/2018
- webpack sync apply
- "name" has been removed as not used anyway, use SHORT instead
- eslint changes
- InjectByTag - AIVTagRegexp exposed in config to allow [AIV] tag modifications
- comma fix in InjectByTag regexp
- query has on filename has been fixed
## [1.0.0] - 25/08/2017
- Date format can now be specified for InjectAsComment
- Date format can now be specified for InjectByTag

View File

@ -1,101 +0,0 @@
// [AIV_SHORT] Version: 0.13.36, Thursday, March 15th, 2018, 7:57:59 AM
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
var html = __webpack_require__(1);
/**
* Sample code
* @type {number}
*/
var myVariable = 5;
var test = function(val) {
return val * val;
};
test(myVariable);
/***/ }),
/* 1 */
/***/ (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>7:57:59</span> <span>0.13.36_7:57:59</span> <span>V:0.13.36 Date:7:57:59</span> <span>Version 0.13.36 , 7:57:59</span></body></html>"
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(0);
/***/ })
/******/ ]);

100
demo/dist/js/index.js vendored
View File

@ -1,100 +0,0 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
var html = __webpack_require__(1);
/**
* Sample code
* @type {number}
*/
var myVariable = 5;
var test = function(val) {
return val * val;
};
test(myVariable);
/***/ }),
/* 1 */
/***/ (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>7:58:33</span> <span>0.13.36_7:58:33</span> <span>V:0.13.36 Date:7:58:33</span> <span>Version 0.13.36 , 7:58:33</span></body></html>"
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(0);
/***/ })
/******/ ]);

2
demo/dist/js/main.js vendored Normal file
View File

@ -0,0 +1,2 @@
// [AIV_SHORT] Version: 0.14.0, Thursday, March 15th, 2018, 11:02:44 AM
!function(n){var t={};function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=2)}([function(n,t,e){e(1)},function(n,t){n.exports="<!DOCTYPE html><html lang=en><head><meta charset=UTF-8><title>Title</title></head><body><span>0.14.0</span> <span>11:02:44</span> <span>0.14.0_11:02:44</span> <span>V:0.14.0 Date:11:02:44</span> <span>Version 0.14.0 , 11:02:44</span></body></html>"},function(n,t,e){n.exports=e(0)}]);

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "example-using-inject",
"version": "0.13.36",
"version": "0.14.0",
"description": "This is an example how to use webpack-auto-inject-version plugin in webpack",
"scripts": {
"start": "webpack --config ./webpack.conf.js",
@ -11,9 +11,11 @@
"author": "Radoslaw Swiat",
"license": "ISC",
"devDependencies": {
"compression-webpack-plugin": "^1.1.11",
"html-loader": "^0.4.5",
"html-minify-loader": "^1.1.0",
"raw-loader": "^0.5.1",
"uglifyjs-webpack-plugin": "^1.2.3",
"webpack": "^2.3.3",
"webpack-auto-inject-version": "^0.5.10"
}

View File

@ -1,10 +1,14 @@
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
// Require WebpackAutoInject from npm installed modules ( preferred )
// var WebpackAutoInject = require('webpack-auto-inject-version');
// Require WebpackAutoInject from dist - dev purpose only ( do not use the below line )
const WebpackAutoInject = require('../dist/WebpackAutoInjectVersion');
module.exports = {
watch: true,
entry: {
@ -14,10 +18,12 @@ module.exports = {
extensions: ['.js', '.html'],
},
output: {
filename: 'js/[name].js?[chunkhash]',
// filename: '[name]-bundle.js',
// path: path.resolve(process.cwd(), 'dist'),
// publicPath: '/', // Public path to 'dist' scope in production
filename: 'js/main.js?[chunkhash]',
path: path.resolve(process.cwd(), 'dist'),
chunkFilename: 'js/[id].js?[chunkhash]',
publicPath: '/', // Public path to 'dist' scope in production
chunkFilename: 'js/main.js?[chunkhash]',
},
module: {
loaders: [
@ -61,5 +67,9 @@ module.exports = {
},
},
}),
new CompressionPlugin({
algorithm: 'gzip',
}),
new UglifyJsPlugin(),
],
};

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
{
"name": "webpack-auto-inject-version",
"version": "1.0.0",
"version": "1.1.0",
"repository": "radswiat/webpack-auto-inject-version",
"description": "Webpack plugin for auto inject version from package.json",
"main": "dist/WebpackAutoInjectVersion.js",
"scripts": {
"start": "babel-node tools/compile.js",
"start:watch": "babel-node tools/compile-watch.js",
"eslint": "eslint ./src/**"
},
"author": "Radoslaw Swiat",

View File

@ -0,0 +1,34 @@
// this.context.compiler.plugin('compilation', (compilation) => {
// console.log(chalk.red('COOOMPILE!'));
// console.log(compilation.assets)
//
// compilation.plugin('optimize-chunk-assets', (chunks, cb) => {
// //unless you specified multiple entries in your config
// //there's only one chunk at this point
// chunks.forEach((chunk) => {
// //chunks have circular references to their modules
// console.log(chalk.green('----- module -----'));
// // console.log(JSON.stringify(chunk));
//
// chunk.files.forEach((file) => {
// console.log('--------------------------');
// console.log(file);
// // console.log(compilation.assets[file]);
// // compilation.assets[file] = 'asdasdadas';
//
// // const asset = `VERSION! ${endOfLine} ${compilation.assets[file].source()} `;
// // compilation.assets[file].source = () => asset;
// // console.log('--------- end -----------------');
//
// const assetFile = compilation.assets[file];
// const assetFilename = file;
// const ext = path.extname(assetFilename).replace(/(\?)(.){0,}/, '');
// console.log('ext', ext);
// const newContent = this.handleAssetFile(ext, assetFile);
// console.log(newContent);
// });
// });
// cb();
// });
//
// });

View File

@ -1,6 +1,7 @@
import semver from 'semver';
import path from 'path';
import fs from 'fs';
import semver from 'semver';
import { isArgv } from 'core/utils';
import log from 'core/log';
import config from 'config';
@ -15,20 +16,24 @@ export default class AutoIncreaseVersion {
/**
* Apply will be called from main class
*
* @protected
* @returns {Promise}
* @return {Promise}
*/
apply() {
// setup promise
const promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
// when runInWatchMode
// we have to register AutoIncreaseVersion instead of firing it straight away
if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) {
if (this.context.compiler) {
this.context.compiler.plugin('emit', async (compilation, cb) => {
await new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
this.start();
});
this.context.compiler.plugin('emit', (compilation, cb) => {
this.start();
cb();
});
}
@ -36,11 +41,8 @@ export default class AutoIncreaseVersion {
}
// when runInWatchMode is off
return new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
this.start();
});
this.start();
return promise;
}
/**
@ -65,7 +67,7 @@ export default class AutoIncreaseVersion {
/**
* Open package file
* @returns {any}
* @return {any}
*/
openPackageFile() {
try {
@ -76,6 +78,7 @@ export default class AutoIncreaseVersion {
)
);
} catch (err) {
console.log(err);
return null;
}
}
@ -106,7 +109,7 @@ export default class AutoIncreaseVersion {
* Increase major
*/
major() {
let newVersion = semver.inc(this.packageFile.version, 'major');
const newVersion = semver.inc(this.packageFile.version, 'major');
this.closePackageFile(newVersion);
}
@ -114,7 +117,7 @@ export default class AutoIncreaseVersion {
* Increase minor
*/
minor() {
let newVersion = semver.inc(this.packageFile.version, 'minor');
const newVersion = semver.inc(this.packageFile.version, 'minor');
this.closePackageFile(newVersion);
}
@ -122,7 +125,7 @@ export default class AutoIncreaseVersion {
* Increase patch
*/
patch() {
let newVersion = semver.inc(this.packageFile.version, 'patch');
const newVersion = semver.inc(this.packageFile.version, 'patch');
this.closePackageFile(newVersion);
}
}

View File

@ -1,6 +1,8 @@
import path from 'path';
import config from 'config';
import log from 'core/log';
import tags from './tags';
const endOfLine = require('os').EOL;
@ -20,38 +22,67 @@ export default class InjectAsComment {
/**
* Apply will be called from main class
* - hook into webpack emit
* - iterate complication.assets files
* - handle each file
* @protected
* @returns {Promise}
* @return {Promise}
*/
apply() {
// bind into emit hook
this.context.compiler.plugin('emit', (compilation, cb) => {
for (let basename in compilation.assets) {
let ext = path.extname(basename);
let asset = compilation.assets[basename];
switch (ext) {
case '.js' :
this.injectIntoJs(asset);
break;
case '.html' :
this.injectIntoHtml(asset);
break;
case '.css' :
this.injectIntoCss(asset);
break;
default:
break;
}
// iterate over all assets file in compilation
for (const basename in compilation.assets) {
// bug fix, extname is not able to handle chunk file params index.js?random123
const ext = path.extname(basename).replace(/(\?)(.){0,}/, '');
const asset = compilation.assets[basename];
this._handleAssetFile(ext, asset);
log.info(`InjectAsComment : match : ${basename} : injected : ${this.context.version}`);
}
cb();
});
return new Promise((resolve) => { resolve(); });
}
/**
* Handle asset file
* - call suitable inject based on file extension
* @param ext
* @param asset
* @private
*/
_handleAssetFile(ext, asset) {
switch (ext) {
case '.js': {
this.injectIntoJs(asset);
break;
}
case '.html': {
this.injectIntoHtml(asset);
break;
}
case '.css': {
this.injectIntoCss(asset);
break;
}
default:
break;
}
}
/**
* Parse tags
* - parse inject tags eg {version}, {date}
* @private
*
* @param baseOpen
* @param baseClose
*
* @return {string}
*/
parseTags(baseOpen, baseClose) {
let tagPattern = this.context.config.componentsOptions.InjectAsComment.tag;
tagPattern = tagPattern.replace(/(\{([a-zA-Z]+)\})/g, (tag) => {
let tagName = tag.replace(/(\{|\})/g, '');
const tagName = tag.replace(/(\{|\})/g, '');
if (typeof tags[tagName] === 'function') {
return tags[tagName](this.context);
}
@ -61,18 +92,42 @@ export default class InjectAsComment {
return `${baseOpen} ${tagPattern} ${baseClose}`;
}
/**
* Inject into css
* - inject tag comment into css asset file
* - format: / ** .... ** /
* @private
*
* @param asset
*/
injectIntoCss(asset) {
let modAsset = this.parseTags(`/** [${config.SHORT}] `, ' **/ ');
modAsset += `${endOfLine} ${asset.source()} `;
asset.source = () => modAsset;
}
/**
* Inject into html
* - inject tag comment into html asset file
* - format: <!-- ... -->
* @private
*
* @param asset
*/
injectIntoHtml(asset) {
let modAsset = this.parseTags(`<!-- [${config.SHORT}] `, ' --> ');
modAsset += `${endOfLine} ${asset.source()} `;
asset.source = () => modAsset;
}
/**
* Inject into JS
* - inject tag comment into JS asset file
* - format: // ...
* @private
*
* @param asset
*/
injectIntoJs(asset) {
let modAsset = this.parseTags(`// [${config.SHORT}] `, ' ');
modAsset += `${endOfLine} ${asset.source()} `;

View File

@ -7,5 +7,5 @@ export default {
},
date: () => {
return dateFormat(new Date(), config.componentsOptions.InjectAsComment.dateFormat);
}
},
};

View File

@ -1,5 +1,4 @@
export default {
NAME: 'Auto Inject Version CONFIG',
SHORT: 'AIV_SHORT',
SILENT: false,
PACKAGE_JSON_PATH: './package.json',

View File

@ -1,6 +1,8 @@
import config from 'config';
import chalk from 'chalk';
import config from 'config';
import { isArgv } from 'core/utils';
const endOfLine = require('os').EOL;
class Log {
@ -21,7 +23,7 @@ class Log {
/**
* Get console log head
* @returns {string}
* @return {string}
*/
getHead() {
return endOfLine + chalk.bgYellow.black('[AIV] : ');
@ -29,6 +31,7 @@ class Log {
/**
* Get log text by ID from config file
* @param id
*/
getText(id) {
return config.LOGS_TEXT[id];
@ -37,7 +40,7 @@ class Log {
/**
* Call any type
* @param type
* @param msg
* @param msgId
*/
call(type, msgId) {
if (typeof this[type] === 'function') {

View File

@ -1,12 +1,13 @@
let argv = require('optimist').argv;
const argv = require('optimist').argv;
/**
* Get argv from webpack env[argv]
* Since webpack 2.0 we have to pass args by the env
* example:
* - webpack --config ./webpack.conf.js --env.patch
*
* @param arg
* @returns {boolean}
* @return {boolean}
*/
export function isArgv(arg) {
if (typeof argv.env === 'undefined') {

View File

@ -1,3 +1,4 @@
/* global define */
import fs from 'fs';
import path from 'path';
@ -25,7 +26,7 @@ export default class WebpackAutoInject {
);
this.version = packageFile.version;
log.call('info', 'AIS_START');
this.executeNoneWebpackComponents();
this._executeNoneWebpackComponents();
}
/**
@ -36,7 +37,7 @@ export default class WebpackAutoInject {
*/
setConfig(userConfig) {
this.config = merge(config, userConfig);
console.log(this.config);
// lets convert all components names to lowercase - to prevent issues
this.config.components = transform(this.config.components, (result, val, key) => {
result[key.toLowerCase()] = val;
@ -47,12 +48,14 @@ export default class WebpackAutoInject {
* Webpack apply call,
* when webpack is initialized and
* plugin has been called by webpack
* @param compiler
*
* @protected
*
* @param compiler
*/
async apply(compiler) {
apply(compiler) {
this.compiler = compiler;
await this.executeWebpackComponents();
this._executeWebpackComponents();
}
/**
@ -60,8 +63,8 @@ export default class WebpackAutoInject {
* - runs as soon as possible,
* > without waiting for webpack init
*/
async executeNoneWebpackComponents() {
await this.executeComponent([AutoIncreaseVersion]);
_executeNoneWebpackComponents() {
this._executeComponent([AutoIncreaseVersion]);
}
/**
@ -69,19 +72,23 @@ export default class WebpackAutoInject {
* - runs when webpack is initialized
* and plugins is called by webpack
*/
async executeWebpackComponents() {
_executeWebpackComponents() {
if (config.componentsOptions.AutoIncreaseVersion.runInWatchMode) {
await this.executeComponent([AutoIncreaseVersion]);
this._executeComponent([AutoIncreaseVersion]);
}
await this.executeComponent([InjectAsComment, InjectByTag]);
this._executeComponent([InjectAsComment, InjectByTag]);
}
/**
* Execute components,
* - general layer for comp execution
* - used for both, webpack and non webpack comp
*
* @private
*
* @param components
*/
async executeComponent(components) {
_executeComponent(components) {
// no more components,
// finish
if (!components.length) {
@ -89,22 +96,22 @@ export default class WebpackAutoInject {
}
// take first component class
let ComponentClass = components.shift();
const ComponentClass = components.shift();
// if component is disabled, call next component
if (!this.config.components[ComponentClass.componentName.toLowerCase()]) {
await this.executeComponent(components);
this._executeComponent(components);
return;
}
// execute component
let inst = new ComponentClass(this);
const inst = new ComponentClass(this);
// await for apply to finish
await inst.apply();
inst.apply();
// call next tick
await this.executeComponent(components);
this._executeComponent(components);
}
}

17
tools/compile-watch.js Normal file
View File

@ -0,0 +1,17 @@
import gutil from 'gutil';
import webpack from 'webpack';
import webpackConfig from './webpack.conf';
function run() {
console.log('compiling');
const compiler = webpack(webpackConfig);
compiler.watch({}, (err, stats) => {
gutil.log('[webpack:build]', stats.toString({
chunks: false, // Makes the build much quieter
colors: true,
}));
});
}
run();

View File

@ -1,14 +1,15 @@
import webpack from 'webpack';
import gutil from 'gutil';
import webpack from 'webpack';
import webpackConfig from './webpack.conf';
function run() {
console.log('compiling');
let compiler = webpack(webpackConfig);
const compiler = webpack(webpackConfig);
compiler.run((err, stats) => {
gutil.log('[webpack:build]', stats.toString({
chunks: false, // Makes the build much quieter
colors: true
colors: true,
}));
});
}

View File

@ -2,7 +2,7 @@ import path from 'path';
export default {
target: 'node',
entry: ['./src/main.js'],
entry: ['./src/webpack-auto-inject.js'],
resolve: {
extensions: ['.js'],
},