forked from Tencent/Hippy
-
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(hermes): demo build script support hermes
- Loading branch information
1 parent
6a1c29f
commit c57bc36
Showing
18 changed files
with
1,655 additions
and
23 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
80 changes: 80 additions & 0 deletions
80
driver/js/examples/hippy-react-demo/scripts/hippy-webpack.hermes.android-vendor.js
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,80 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); | ||
|
||
const platform = 'android'; | ||
const engine = 'hermes'; | ||
|
||
module.exports = { | ||
mode: 'production', | ||
bail: true, | ||
entry: { | ||
vendor: [path.resolve(__dirname, './vendor.js')], | ||
}, | ||
output: { | ||
filename: `[name].${platform}.js`, | ||
path: path.resolve(`./dist/${platform}_${engine}/`), | ||
globalObject: '(0, eval)("this")', | ||
library: 'hippyReactBase', | ||
}, | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
__PLATFORM__: JSON.stringify(platform), | ||
}), | ||
new CaseSensitivePathsPlugin(), | ||
new webpack.DllPlugin({ | ||
context: path.resolve(__dirname, '..'), | ||
path: path.resolve(__dirname, `../dist/${platform}/[name]-manifest.json`), | ||
name: 'hippyReactBase', | ||
}), | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js)$/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
chrome: 41, | ||
}, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
['@babel/plugin-proposal-class-properties'], | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.json'], | ||
// if node_modules path listed below is not your repo directory, change it. | ||
modules: [path.resolve(__dirname, '../node_modules')], | ||
alias: (() => { | ||
const aliases = {}; | ||
// If hippy-react was built exist then make a alias | ||
// Remove the section if you don't use it | ||
const hippyReactPath = path.resolve(__dirname, '../../../packages/hippy-react'); | ||
if (fs.existsSync(path.resolve(hippyReactPath, 'dist/index.js'))) { | ||
console.warn(`* Using the @hippy/react in ${hippyReactPath}`); | ||
aliases['@hippy/react'] = hippyReactPath; | ||
} else { | ||
console.warn('* Using the @hippy/react defined in package.json'); | ||
} | ||
|
||
return aliases; | ||
})(), | ||
}, | ||
}; |
113 changes: 113 additions & 0 deletions
113
driver/js/examples/hippy-react-demo/scripts/hippy-webpack.hermes.android.js
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,113 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); | ||
const HippyDynamicImportPlugin = require('@hippy/hippy-dynamic-import-plugin'); | ||
const pkg = require('../package.json'); | ||
const manifest = require('../dist/android/vendor-manifest.json'); | ||
|
||
const platform = 'android'; | ||
const engine = 'hermes'; | ||
|
||
module.exports = { | ||
mode: 'production', | ||
bail: true, | ||
entry: { | ||
index: ['regenerator-runtime', path.resolve(pkg.main)], | ||
}, | ||
output: { | ||
filename: `[name].${platform}.js`, | ||
path: path.resolve(`./dist/${platform}_${engine}/`), | ||
globalObject: '(0, eval)("this")', | ||
// CDN path can be configured to load children bundles from remote server | ||
// publicPath: 'https://xxx/hippy/hippyReactDemo/', | ||
}, | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
__PLATFORM__: JSON.stringify(platform), | ||
}), | ||
new CaseSensitivePathsPlugin(), | ||
new webpack.DllReferencePlugin({ | ||
context: path.resolve(__dirname, '..'), | ||
manifest, | ||
}), | ||
new HippyDynamicImportPlugin(), | ||
// LimitChunkCountPlugin can control dynamic import ability | ||
// Using 1 will prevent any additional chunks from being added | ||
// new webpack.optimize.LimitChunkCountPlugin({ | ||
// maxChunks: 1, | ||
// }), | ||
// use SourceMapDevToolPlugin can generate sourcemap file | ||
// new webpack.SourceMapDevToolPlugin({ | ||
// test: /\.(js|jsbundle|css|bundle)($|\?)/i, | ||
// filename: '[file].map', | ||
// }), | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(jsx?)$/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
sourceType: 'unambiguous', | ||
presets: [ | ||
'@babel/preset-react', | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
chrome: 41, | ||
}, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
['@babel/plugin-proposal-class-properties'], | ||
['@babel/plugin-proposal-decorators', { legacy: true }], | ||
['@babel/plugin-transform-runtime', { regenerator: true }], | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /\.(png|jpe?g|gif)$/i, | ||
use: [{ | ||
loader: 'url-loader', | ||
options: { | ||
// if you would like to use base64 for picture, uncomment limit: true | ||
// limit: true, | ||
limit: 8192, | ||
fallback: 'file-loader', | ||
name: '[name].[ext]', | ||
outputPath: 'assets/', | ||
}, | ||
}], | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.json'], | ||
// if node_modules path listed below is not your repo directory, change it. | ||
modules: [path.resolve(__dirname, '../node_modules')], | ||
alias: (() => { | ||
const aliases = {}; | ||
|
||
// If hippy-react was built exist then make a alias | ||
// Remove the section if you don't use it | ||
const hippyReactPath = path.resolve(__dirname, '../../../packages/hippy-react'); | ||
if (fs.existsSync(path.resolve(hippyReactPath, 'dist/index.js'))) { | ||
console.warn(`* Using the @hippy/react in ${hippyReactPath}`); | ||
aliases['@hippy/react'] = hippyReactPath; | ||
} else { | ||
console.warn('* Using the @hippy/react defined in package.json'); | ||
} | ||
|
||
return aliases; | ||
})(), | ||
}, | ||
}; |
81 changes: 81 additions & 0 deletions
81
driver/js/examples/hippy-react-demo/scripts/hippy-webpack.hermes.ios-vendor.js
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,81 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); | ||
|
||
const platform = 'ios'; | ||
const engine = 'hermes'; | ||
|
||
module.exports = { | ||
mode: 'production', | ||
bail: true, | ||
entry: { | ||
vendor: [path.resolve(__dirname, './vendor.js')], | ||
}, | ||
output: { | ||
filename: `[name].${platform}.js`, | ||
path: path.resolve(`./dist/${platform}_${engine}/`), | ||
globalObject: '(0, eval)("this")', | ||
library: 'hippyReactBase', | ||
}, | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
__PLATFORM__: JSON.stringify(platform), | ||
}), | ||
new CaseSensitivePathsPlugin(), | ||
new webpack.DllPlugin({ | ||
context: path.resolve(__dirname, '..'), | ||
path: path.resolve(__dirname, `../dist/${platform}/[name]-manifest.json`), | ||
name: 'hippyReactBase', | ||
}), | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(jsx?)$/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
ios: 8, | ||
chrome: 41, | ||
}, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
['@babel/plugin-proposal-class-properties'], | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.json'], | ||
// if node_modules path listed below is not your repo directory, change it. | ||
modules: [path.resolve(__dirname, '../node_modules')], | ||
alias: (() => { | ||
const aliases = {}; | ||
// If hippy-react was built exist then make a alias | ||
// Remove the section if you don't use it | ||
const hippyReactPath = path.resolve(__dirname, '../../../packages/hippy-react'); | ||
if (fs.existsSync(path.resolve(hippyReactPath, 'dist/index.js'))) { | ||
console.warn(`* Using the @hippy/react in ${hippyReactPath}`); | ||
aliases['@hippy/react'] = hippyReactPath; | ||
} else { | ||
console.warn('* Using the @hippy/react defined in package.json'); | ||
} | ||
|
||
return aliases; | ||
})(), | ||
}, | ||
}; |
Oops, something went wrong.