基于 easywebpack 的 Weex Native 和 Weex Web 打包构建解决方案.
$ npm i easywebpack-weex --save-dev
const weex = require('easywebpack-weex');
// 获取 webpack weex 配置
const webpackConfig = weex.getWeexWebpackConfig({
env: process.env.BUILD_ENV, // 支持 dev,test,local 模式
entry: {
index: 'src/app.js'
}
});
// 获取 webpack web 配置
const webpackConfig = weex.getWebWebpackConfig({
entry: {
index: 'src/app.js'
}
});
// 获取 webpack weex 和 web 配置
const webpackConfig = weex.getWebpackConfig({
entry: {
index: 'src/app.js'
}
});
- 使用 webpack-cli 开发构建服务
webpack --config webpack.config.js
- 使用 easywebpack 内置开发构建服务
const weex = require('easywebpack-weex');
if (process.env.NODE_ENV === 'development') {
// development mode: webpack building and start webpack hot server
weex.server(webpackConfig);
} else {
// build file to disk
weex.build(webpackConfig);
}
easywebpack-weex-boilerplate Weex构建项目骨架