-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:support webpack weex and weex-web
- Loading branch information
0 parents
commit 2d48c92
Showing
32 changed files
with
574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"presets": ["es2015", "stage-2"], | ||
"plugins": [ | ||
'add-module-exports', | ||
["transform-runtime", { | ||
"polyfill": true, | ||
"regenerator": true | ||
}] | ||
], | ||
"comments": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
test/fixtures | ||
coverage | ||
test/web | ||
node_modules | ||
public | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"extends": "eslint", | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
"mocha": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
2 | ||
], | ||
"new-cap": "off", | ||
"newline-after-var": "off", | ||
"no-invalid-this": "off", | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"guard-for-in": "off", | ||
"no-console": "off", | ||
"no-undefined": "off", | ||
"array-bracket-spacing": "off", | ||
"no-unused-expressions": "off", | ||
"func-style": [ | ||
"error", | ||
"expression" | ||
], | ||
"comma-dangle": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.js linguist-language=javascript | ||
*.css linguist-language=javascript | ||
*.html linguist-language=javascript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
logs/ | ||
npm-debug.log | ||
node_modules/ | ||
coverage/ | ||
.idea/ | ||
run/ | ||
.DS_Store | ||
*.swp | ||
.vscode | ||
*.iml | ||
dist | ||
public/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- '6' | ||
- '7' | ||
- '8' | ||
install: | ||
- npm i npminstall && npminstall | ||
script: | ||
- npm run ci | ||
after_script: | ||
- npminstall codecov && codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 sky. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# easywebpack-weex | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![David deps][david-image]][david-url] | ||
[![Known Vulnerabilities][snyk-image]][snyk-url] | ||
[![npm download][download-image]][download-url] | ||
|
||
[npm-image]: https://img.shields.io/npm/v/easywebpack-weex.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/easywebpack-weex | ||
[travis-image]: https://img.shields.io/travis/hubcarl/easywebpack-weex.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/hubcarl/easywebpack-weex | ||
[codecov-image]: https://img.shields.io/codecov/c/github/hubcarl/easywebpack-weex.svg?style=flat-square | ||
[codecov-url]: https://codecov.io/github/hubcarl/easywebpack-weex?branch=master | ||
[david-image]: https://img.shields.io/david/hubcarl/easywebpack-weex.svg?style=flat-square | ||
[david-url]: https://david-dm.org/hubcarl/easywebpack-weex | ||
[snyk-image]: https://snyk.io/test/npm/easywebpack-weex/badge.svg?style=flat-square | ||
[snyk-url]: https://snyk.io/test/npm/easywebpack-weex | ||
[download-image]: https://img.shields.io/npm/dm/easywebpack-weex.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/easywebpack-weex | ||
|
||
egg webpack building solution for vue | ||
|
||
## Install | ||
|
||
```bash | ||
$ npm i easywebpack-weex --save | ||
``` | ||
|
||
## Usage | ||
|
||
### webpack common config `base.js` | ||
|
||
```js | ||
'use strict'; | ||
const path = require('path'); | ||
const VueWebpack = require('easywebpack-weex'); | ||
const merge = VueWebpack.merge; | ||
const baseDir = path.join(__dirname, '../../../'); | ||
const webpackConfig = { | ||
baseDir, | ||
build: { | ||
entry: path.join(baseDir, 'test/web/page') | ||
} | ||
}; | ||
const WebpackBaseBuilder = WebpackBuilder => class extends WebpackBuilder { | ||
constructor(config) { | ||
super(merge(webpackConfig, config)); | ||
this.setAlias('app', path.join(this.config.baseDir, 'test/web/framework/vue/app')); | ||
this.setAlias('component', path.join(this.config.baseDir, 'test/web/component')); | ||
} | ||
}; | ||
module.exports = WebpackBaseBuilder; | ||
``` | ||
|
||
### webpack weex config `weex.js` | ||
|
||
```js | ||
'use strict'; | ||
const WeexWebpack = require('easywebpack-weex'); | ||
const WebpackWeexBuilder = VueWebpack.WebpackWeexBuilder; | ||
const WebpackBaseBuilder = require('../base'); | ||
class WeexBuilder extends WebpackBaseBuilder(WebpackWeexBuilder) { | ||
} | ||
module.exports = new WeexBuilder().create(); | ||
``` | ||
|
||
### webpack weex web config `web.js` | ||
|
||
```js | ||
'use strict'; | ||
const WeexWebpack = require('easywebpack-weex'); | ||
const WebpackWebBuilder = WeexWebpack.WebpackWebBuilder; | ||
const WebpackBaseBuilder = require('../base'); | ||
class WeexWebBuilder extends WebpackBaseBuilder(WebpackWebBuilder) { | ||
} | ||
module.exports = new WeexWebBuilder().create(); | ||
``` | ||
|
||
### command run entry file `build.js` | ||
|
||
```js | ||
const WeexWebpack = require('easywebpack-weex'); | ||
const weexConfig = require('./weex'); | ||
const webConffig = require('./web'); | ||
const config = { | ||
webpackConfig: [weexConfig, webConffig] | ||
}; | ||
|
||
if (process.env.NODE_SERVER) { | ||
// development mode: webpack building and start webpack hot server | ||
WeexWebpack.server(config); | ||
} else { | ||
// build file to disk | ||
WeexWebpack.build(config); | ||
} | ||
``` | ||
|
||
### commmand run | ||
|
||
```js | ||
{ | ||
"scripts": { | ||
"build": "cross-env NODE_ENV=production node test/build", | ||
"build-dev": "cross-env NODE_ENV=development node test/build", | ||
"build-weex": "BUILD_ENV=weex npm run build", | ||
"build-web": "BUILD_ENV=web npm run build", | ||
"build-weex-dev": "BUILD_ENV=weex npm run build-dev", | ||
"build-web-dev": "BUILD_ENV=web npm run build-dev", | ||
"start" : "cross-env NODE_SERVER=true NODE_ENV=development node test/build" | ||
} | ||
} | ||
``` | ||
|
||
```bash | ||
|
||
npm start | ||
|
||
``` | ||
|
||
|
||
## Example | ||
|
||
 | ||
|
||
 | ||
|
||
see [weex example](test/web) and [weex webpack build config](test/build) for more detail. | ||
|
||
## Questions & Suggestions | ||
|
||
Please open an issue [here](https://github.com/hubcarl/easywebpack-weex). | ||
|
||
## License | ||
|
||
[MIT](LICENSE) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
const WeexWebpackTool = require('./tool'); | ||
exports.EasyWebpack = require('easywebpack'); | ||
exports.webpack = exports.EasyWebpack.webpack; | ||
exports.merge = exports.EasyWebpack.merge; | ||
exports.WebpackWeexBuilder = require('./lib/weex'); | ||
exports.WebpackWebBuilder = require('./lib/web'); | ||
exports.WeexWebpackTool = WeexWebpackTool; | ||
exports.build = (config, callback) => { | ||
new WeexWebpackTool(config).build(callback); | ||
}; | ||
exports.server = config => { | ||
new WeexWebpackTool(config).server(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
const WebpackBaseBuilder = WebpackBuilder => class extends WebpackBuilder { | ||
constructor(config) { | ||
super(config); | ||
this.setExtensions('.vue'); | ||
} | ||
}; | ||
module.exports = WebpackBaseBuilder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const EasyWebpack = require('easywebpack'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const WebpackBaseBuilder = require('./base'); | ||
class WebpackServerBuilder extends WebpackBaseBuilder(EasyWebpack.WebpackClientBuilder) { | ||
constructor(config) { | ||
super(config); | ||
this.setPrefix('web'); | ||
this.setStyleLoaderName('vue-style-loader'); | ||
this.addLoader(/\.html$/, 'vue-html-loader'); | ||
this.addLoader(/\.vue$/, 'vue-loader', () => { | ||
const options = EasyWebpack.Loader.getStyleLoaderOption(this.getStyleConfig()); | ||
options.compilerModules = [{ | ||
postTransformNode: el => { | ||
el.staticStyle = `$processStyle(${el.staticStyle})`; | ||
el.styleBinding = `$processStyle(${el.styleBinding})`; | ||
} | ||
}]; | ||
return { options }; | ||
}); | ||
Object.keys(this.options.entry).forEach(entryName => { | ||
const isCommonsChunk = this.config.build.commonsChunk.some(chunk => chunk === entryName); | ||
if (!isCommonsChunk) { | ||
const chunks = [].concat(this.config.build.commonsChunk).concat(entryName); | ||
this.addPlugin(HtmlWebpackPlugin, { | ||
chunks, | ||
filename: `${this.prefix}/${entryName}.html`, | ||
template: path.join(this.config.baseDir, 'test/web/view/layout.html'), | ||
inject: true, | ||
minify: { | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
removeAttributeQuotes: true | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
module.exports = WebpackServerBuilder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
const EasyWebpack = require('easywebpack'); | ||
const webpack = EasyWebpack.webpack; | ||
const merge = EasyWebpack.merge; | ||
const WebpackBaseBuilder = require('./base'); | ||
|
||
class WebpackClientBuilder extends WebpackBaseBuilder(EasyWebpack.WebpackClientBuilder) { | ||
constructor(config) { | ||
super(merge({ build: { commonsChunk: null } }, config)); | ||
this.setPrefix('weex'); | ||
this.setCssExtract(false); | ||
this.setStyleLoaderName('weex-vue-loader/lib/style-loader'); | ||
this.addLoader(/\.vue$/, 'weex-loader', () => ({ | ||
options: EasyWebpack.Loader.getStyleLoaderOption(this.getStyleConfig()) | ||
})); | ||
this.addPlugin(webpack.BannerPlugin, { banner: '// { "framework": "Vue" }\n', raw: true }); | ||
this.addPlugin(webpack.DefinePlugin, { | ||
'process.env': { | ||
PLATFORM: '"weex"' | ||
} | ||
}); | ||
} | ||
} | ||
module.exports = WebpackClientBuilder; |
Oops, something went wrong.