Add webpack
This commit is contained in:
parent
9ff7984c4c
commit
99adf5138c
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
dist
|
||||||
|
5265
package-lock.json
generated
5265
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -7,9 +7,15 @@
|
|||||||
"example": "examples"
|
"example": "examples"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"start": "node scripts/server.js",
|
||||||
|
"build": "rimraf dist && webpack --config scripts/webpack.config.prod.js",
|
||||||
|
"prepublishOnly": "npm run build",
|
||||||
"test": "mocha",
|
"test": "mocha",
|
||||||
"lint": "eslint src"
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
|
"browser": {
|
||||||
|
"./src/worker/node/index.js": "./src/worker/browser/index.js"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/jeromewu/ffmpeg.js.git"
|
"url": "git+https://github.com/jeromewu/ffmpeg.js.git"
|
||||||
@ -29,9 +35,17 @@
|
|||||||
"@ffmpeg/core": "^0.1.0"
|
"@ffmpeg/core": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.6.4",
|
||||||
|
"@babel/preset-env": "^7.6.3",
|
||||||
|
"babel-loader": "^8.0.6",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"eslint": "^6.1.0",
|
"eslint": "^6.1.0",
|
||||||
"eslint-config-airbnb-base": "^14.0.0",
|
"eslint-config-airbnb-base": "^14.0.0",
|
||||||
"eslint-plugin-import": "^2.18.2",
|
"eslint-plugin-import": "^2.18.2",
|
||||||
"mocha": "^6.2.2"
|
"express": "^4.17.1",
|
||||||
|
"mocha": "^6.2.2",
|
||||||
|
"webpack": "^4.41.2",
|
||||||
|
"webpack-cli": "^3.3.9",
|
||||||
|
"webpack-dev-middleware": "^3.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
scripts/.eslintrc
Normal file
5
scripts/.eslintrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"import/no-extraneous-dependencies": 0
|
||||||
|
}
|
||||||
|
}
|
17
scripts/server.js
Normal file
17
scripts/server.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const webpack = require('webpack');
|
||||||
|
const middleware = require('webpack-dev-middleware');
|
||||||
|
const express = require('express');
|
||||||
|
const path = require('path');
|
||||||
|
const cors = require('cors');
|
||||||
|
const webpackConfig = require('./webpack.config.dev');
|
||||||
|
|
||||||
|
const compiler = webpack(webpackConfig);
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.use(cors());
|
||||||
|
app.use('/', express.static(path.resolve(__dirname, '..')));
|
||||||
|
app.use(middleware(compiler, { publicPath: '/dist', writeToDisk: true }));
|
||||||
|
|
||||||
|
module.exports = app.listen(3000, () => {
|
||||||
|
console.log('Server is running on port 3000');
|
||||||
|
});
|
23
scripts/webpack.config.common.js
Normal file
23
scripts/webpack.config.common.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
module.exports = {
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.m?js$/,
|
||||||
|
exclude: /(node_modules|bower_components)/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
targets: 'last 2 versions',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
39
scripts/webpack.config.dev.js
Normal file
39
scripts/webpack.config.dev.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const common = require('./webpack.config.common');
|
||||||
|
|
||||||
|
const genConfig = ({
|
||||||
|
entry, filename, library, libraryTarget,
|
||||||
|
}) => ({
|
||||||
|
...common,
|
||||||
|
mode: 'development',
|
||||||
|
entry,
|
||||||
|
output: {
|
||||||
|
filename,
|
||||||
|
library,
|
||||||
|
libraryTarget,
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': {
|
||||||
|
FFMPEG_ENV: JSON.stringify('development'),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
devServer: {
|
||||||
|
allowedHosts: ['localhost', '.gitpod.io'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
genConfig({
|
||||||
|
entry: path.resolve(__dirname, '..', 'src', 'index.js'),
|
||||||
|
filename: 'ffmpeg.dev.js',
|
||||||
|
library: 'FFmpeg',
|
||||||
|
libraryTarget: 'umd',
|
||||||
|
}),
|
||||||
|
//genConfig({
|
||||||
|
// entry: path.resolve(__dirname, '..', 'src', 'worker-script', 'browser', 'index.js'),
|
||||||
|
// filename: 'worker.dev.js',
|
||||||
|
//}),
|
||||||
|
];
|
30
scripts/webpack.config.prod.js
Normal file
30
scripts/webpack.config.prod.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const common = require('./webpack.config.common');
|
||||||
|
|
||||||
|
const genConfig = ({
|
||||||
|
entry, filename, library, libraryTarget,
|
||||||
|
}) => ({
|
||||||
|
...common,
|
||||||
|
mode: 'production',
|
||||||
|
devtool: 'source-map',
|
||||||
|
entry,
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, '..', 'dist'),
|
||||||
|
filename,
|
||||||
|
library,
|
||||||
|
libraryTarget,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
genConfig({
|
||||||
|
entry: path.resolve(__dirname, '..', 'src', 'index.js'),
|
||||||
|
filename: 'ffmpeg.min.js',
|
||||||
|
library: 'FFmpeg',
|
||||||
|
libraryTarget: 'umd',
|
||||||
|
}),
|
||||||
|
//genConfig({
|
||||||
|
// entry: path.resolve(__dirname, '..', 'src', 'worker-script', 'browser', 'index.js'),
|
||||||
|
// filename: 'worker.min.js',
|
||||||
|
//}),
|
||||||
|
];
|
Loading…
Reference in New Issue
Block a user