Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor example #477

Merged
merged 2 commits into from
Jun 5, 2018
Merged
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: 8 additions & 9 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Play with OSS right in the browser!

![Demo](screenshot.png?raw=true "OSS in Browser")
<image src="https://img.alicdn.com/tfs/TB1tE5mvTtYBeNjy1XdXXXXyVXa-2538-1386.png" width="1000" height="500"/>

## Browser support

Expand Down Expand Up @@ -30,25 +30,24 @@ access.

### App setup

Fill in your appServer address and bucket name in `app.js`:
Fill in your bucket name and region in `app.js`: (Note: ensure port 9000 is not used)

```js
var appServer = '<your STS app server>';
var bucket = '<your bucket name>';
var region = 'oss-cn-hangzhou';
```

Build the JS file
Then set env

```
npm install && webpack
```

ALI_SDK_STS_ID={your sts accessKeyId} ALI_SDK_STS_SECRET={your sts accessKeySecret} ALI_SDK_STS_ROLE={your rolearn}
```

Then set env and start the server
Start the server

```
ALI_SDK_STS_ID={your sts accessKeyId} ALI_SDK_STS_SECRET={your sts accessKeySecret} ALI_SDK_STS_ROLE={your rolearn} node server/app.js
npm run start

```

Open the `http://localhost:3000` in browser
Expand Down
56 changes: 56 additions & 0 deletions example/config/webpack.dev.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack')

const HtmlWebpackPluginConfig = {
filename: 'index.html',
template: './template/index.html',
inject:'body',
}

module.exports = {
context: path.resolve(__dirname,'../src'),
entry: './main',
output:{
path:path.resolve(__dirname,'../dist'),
filename: './[hash]app.js',
hashDigestLength: 8
},
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.(eot|woff|woff2)$/,
loader: "file-loader"
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
}
]
},
plugins: [
new HtmlWebpackPlugin(HtmlWebpackPluginConfig),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
})
],
devServer: {
contentBase: path.resolve(__dirname, "../dist"),
port: 3000,
open: true, // open browser auto
index:'index.html', // like HtmlWebpackPlugin
inline:true, // default:true
hot:false,
compress:true // compress
}
}
Loading