Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,26 @@ $ npm install spm-webpack -g
```

## Usage

```bash
$ spm-webpack [option] [file]
```

## Added
add spm.build.publicPath args pass to webpack's output.publicPath
[webpack-configuration](https://github.com/webpack/docs/wiki/configuration#outputpublicpath)
```javascript
{
"spm": {
"output": [
"main.js"
],
"build": {
"publicPath": "http://xxx.com/assets/"
}
}
}
```

## LISENCE

Copyright (c) 2015-2114 chencheng. Licensed under the MIT license.
1 change: 1 addition & 0 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function getWebpackOpts(opts, callback) {
},
output: {
path: join(opts.build.dest || 'dist', utils.getPrefix(pkg)),
publicPath: opts.build.publicPath,
filename: name + '.js',
chunkFilename: name + '.js'
},
Expand Down
1 change: 1 addition & 0 deletions lib/getArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var extend = require('extend');
var defaults = {
build: {
dest: 'dist',
publicPath:'',
force: false,
install: true,
uglify: {
Expand Down
9 changes: 9 additions & 0 deletions test/build-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ describe('lib/build.js', function() {
});
assert(dest, 'js-entry-umd');
});

it('arg-publicPath', function*() {
yield build({
debug: true,
cwd: join(fixtures, 'arg-publicPath'),
dest: dest
});
assert(dest, 'arg-publicPath');
});

it('js entry with no package.json', function*() {
yield build({
Expand Down
12 changes: 12 additions & 0 deletions test/expected/arg-publicPath/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
webpackJsonp([1],{

/***/ 2:
/***/ function(module, exports) {


module.exports = 'b';


/***/ }

});
112 changes: 112 additions & 0 deletions test/expected/arg-publicPath/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ var parentJsonpFunction = window["webpackJsonp"];
/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules) {
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, callbacks = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId])
/******/ callbacks.push.apply(callbacks, installedChunks[chunkId]);
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);
/******/ while(callbacks.length)
/******/ callbacks.shift().call(null, __webpack_require__);

/******/ };

/******/ // The module cache
/******/ var installedModules = {};

/******/ // object to store loaded and loading chunks
/******/ // "0" means "already loaded"
/******/ // Array means "loading", array contains callbacks
/******/ var installedChunks = {
/******/ 0:0
/******/ };

/******/ // 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] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };

/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ // Flag the module as loaded
/******/ module.loaded = true;

/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }

/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId, callback) {
/******/ // "0" is the signal for "already loaded"
/******/ if(installedChunks[chunkId] === 0)
/******/ return callback.call(null, __webpack_require__);

/******/ // an array means "currently loading".
/******/ if(installedChunks[chunkId] !== undefined) {
/******/ installedChunks[chunkId].push(callback);
/******/ } else {
/******/ // start chunk loading
/******/ installedChunks[chunkId] = [callback];
/******/ var head = document.getElementsByTagName('head')[0];
/******/ var script = document.createElement('script');
/******/ script.type = 'text/javascript';
/******/ script.charset = 'utf-8';
/******/ script.async = true;

/******/ script.src = __webpack_require__.p + "" + ({}[chunkId]||chunkId) + ".js";
/******/ head.appendChild(script);
/******/ }
/******/ };

/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;

/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;

/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "some-path/";

/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(1);


/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {


__webpack_require__.e/* require */(1, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(2)]; (function(b) {
console.log(b);
}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});


/***/ }
/******/ ]);
4 changes: 4 additions & 0 deletions test/fixtures/arg-publicPath/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

require(['./b.js'], function(b) {
console.log(b);
});
2 changes: 2 additions & 0 deletions test/fixtures/arg-publicPath/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

module.exports = 'b';
10 changes: 10 additions & 0 deletions test/fixtures/arg-publicPath/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"spm": {
"build": {
"publicPath":"some-path/"
},
"output": [
"a.js"
]
}
}