Add webpack
This commit is contained in:
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',
|
||||
//}),
|
||||
];
|
||||
Reference in New Issue
Block a user