Skip to content
This repository has been archived by the owner on Sep 2, 2020. It is now read-only.

Commit

Permalink
update pack to webpack
Browse files Browse the repository at this point in the history
add min.js
  • Loading branch information
hnsylitao committed Aug 14, 2017
1 parent da0b3c9 commit dd9a982
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea
node_modules
node_modules
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules
# build
src
.babelrc
test.js
test.js
webpack.config.js
build/index.js
87 changes: 85 additions & 2 deletions build/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,84 @@
'use strict';
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["linkToFunc"] = factory();
else
root["linkToFunc"] = factory();
})(this, function() {
return /******/ (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;
/******/
/******/ // 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 = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var argumentsToArray = function argumentsToArray(args) {
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
Expand Down Expand Up @@ -70,4 +150,7 @@ Replace.absPath = function (absPath, link) {

exports['default'] = Replace;
module.exports = exports['default'];
//# sourceMappingURL=index.js.map

/***/ })
/******/ ]);
});
1 change: 0 additions & 1 deletion build/index.js.map

This file was deleted.

1 change: 1 addition & 0 deletions build/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "link-to-func",
"version": "1.0.4",
"version": "1.0.5",
"description": "router link to function",
"main": "build/index.js",
"main": "build/index.min.js",
"scripts": {
"build": "babel src/ -d build/ --source-maps"
"build": "npm run clean && webpack",
"clean": "rm -rf build"
},
"repository": {
"type": "git",
Expand All @@ -23,8 +24,11 @@
},
"homepage": "https://github.com/hnsylitao/link-to-func#readme",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1"
"babel-preset-stage-0": "^6.24.1",
"lodash": "^4.17.4",
"webpack": "^3.5.4"
}
}
57 changes: 57 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var path = require('path')
, webpack = require('webpack')
, _ = require('lodash')
, rootPath = path.join(__dirname, './')
, package = require(path.join(rootPath, 'package.json'))
, srcPath = path.join(rootPath, 'src')
, buildPath = path.join(rootPath, 'build')
, libraryName = (function (str) {
return str.split("-").map(function (c, i) {
return i > 0 ? (c.charAt(0).toUpperCase() + c.substring(1)) : c;
}).join('');
})(package.name);

var createConfig = function (config) {
var baseConfig = {
output: {
path: buildPath,
filename: '[name].js',
library: libraryName,
libraryTarget: "umd"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
include: [srcPath],
use: [{
loader: 'babel-loader',
}]
},
],
}
};
return _.assign({}, baseConfig, config);
}

module.exports = [
createConfig({
entry: {
['index']: path.resolve(srcPath, 'index.js')
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
],
}),
createConfig({
entry: {
['index.min']: path.resolve(srcPath, 'index.js')
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
comments: false,
}),
new webpack.NoEmitOnErrorsPlugin(),
],
})
]

0 comments on commit dd9a982

Please sign in to comment.