瀏覽代碼

Facto Webpack Config

sebavan 6 年之前
父節點
當前提交
894fc8884c

+ 6 - 48
gui/webpack.config.js

@@ -1,49 +1,7 @@
-const path = require('path');
-const webpack = require('webpack');
-const babylonExternals = require('../Tools/WebpackPlugins/babylonExternals');
-const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const babylonWebpackConfig = require('../Tools/WebpackPlugins/babylonWebpackConfig');
 
-module.exports = {
-    context: path.resolve(__dirname, './src'),
-    entry: {
-        'babylonjs-gui': path.resolve(__dirname, './src/legacy/legacy.ts'),
-    },
-    output: {
-        path: path.resolve(__dirname, '../dist/preview release/gui'),
-        filename: 'babylon.gui.min.js',
-        libraryTarget: 'umd',
-        library: {
-            root: ["BABYLON", "GUI"],
-            amd: "babylonjs-gui",
-            commonjs: "babylonjs-gui"
-        },
-        umdNamedDefine: true
-    },
-    resolve: {
-        extensions: [".ts"]
-    },
-    externals: [babylonExternals()],
-    devtool: "source-map",
-    module: {
-        rules: [{
-            test: /\.tsx?$/,
-            loader: 'awesome-typescript-loader',
-            options: {
-                configFileName: path.resolve(__dirname, './tsconfig.json'),
-                declaration: false
-            }
-        }]
-    },
-    mode: "production",
-    performance: {
-        hints: false
-    },
-    plugins: [
-        new HardSourceWebpackPlugin(),
-        new webpack.WatchIgnorePlugin([
-            /\.js$/,
-            /\.d\.ts$/,
-            /\.fx$/
-        ])
-    ]
-}
+var config = babylonWebpackConfig({
+    module: "gui"
+});
+
+module.exports = config;

+ 8 - 44
inspector/webpack.config.js

@@ -1,42 +1,14 @@
-const path = require('path');
-const webpack = require('webpack');
-const babylonExternals = require('../Tools/WebpackPlugins/babylonExternals');
-const MiniCssExtractPlugin = require("mini-css-extract-plugin");
-const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const babylonWebpackConfig = require('../Tools/WebpackPlugins/babylonWebpackConfig');
 
-module.exports = {
-    context: path.resolve(__dirname, './src'),
-    entry: {
-        'babylonjs-inspector': path.resolve(__dirname, './src/legacy/legacy.ts'),
-    },
-    output: {
-        path: path.resolve(__dirname, '../dist/preview release/inspector'),
-        filename: 'babylon.inspector.bundle.js',
-        libraryTarget: 'umd',
-        library: {
-            root: "INSPECTOR",
-            amd: "babylonjs-inspector",
-            commonjs: "babylonjs-inspector"
-        },
-        umdNamedDefine: true
-    },
+var config = babylonWebpackConfig({
+    module: "inspector",
     resolve: {
         extensions: [".js", '.ts', ".tsx"],
         alias: {
             "re-resizable$": path.resolve(__dirname, '../node_modules/re-resizable/lib/index.es5.js')
         }
     },
-    externals: [babylonExternals()],
-    devtool: "source-map",
-    module: {
-        rules: [{
-            test: /\.tsx?$/,
-            loader: 'awesome-typescript-loader',
-            options: {
-                configFileName: path.resolve(__dirname, './tsconfig.json'),
-                declaration: false
-            }
-        },
+    moduleRules: [
         {
             test: /\.scss$/,
             use: [
@@ -49,18 +21,8 @@ module.exports = {
         {
             test: /\.css$/,
             use: ['style-loader', 'css-loader']
-        }]
-    },
-    mode: "production",
-    performance: {
-        hints: false
-    },
+        }],
     plugins: [
-        new HardSourceWebpackPlugin(),
-        new webpack.WatchIgnorePlugin([
-            /\.js$/,
-            /\.d\.ts$/
-        ]),
         new MiniCssExtractPlugin({
             // Options similar to the same options in webpackOptions.output
             // both options are optional
@@ -68,4 +30,6 @@ module.exports = {
             chunkFilename: "[id].css"
         })
     ]
-}
+});
+
+module.exports = config;

+ 6 - 47
loaders/webpack.config.js

@@ -1,48 +1,7 @@
-const path = require('path');
-const webpack = require('webpack');
-const babylonExternals = require('../Tools/WebpackPlugins/babylonExternals');
-const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const babylonWebpackConfig = require('../Tools/WebpackPlugins/babylonWebpackConfig');
 
-module.exports = {
-    context: path.resolve(__dirname, './src'),
-    entry: {
-        'babylonjs-loaders': path.resolve(__dirname, './src/legacy/legacy.ts'),
-    },
-    output: {
-        path: path.resolve(__dirname, '../dist/preview release/loaders'),
-        filename: 'babylonjs.loaders.min.js',
-        libraryTarget: 'umd',
-        library: {
-            root: ["LOADERS"],
-            amd: "babylonjs-loaders",
-            commonjs: "babylonjs-loaders"
-        },
-        umdNamedDefine: true
-    },
-    resolve: {
-        extensions: ['.ts']
-    },
-    externals: [babylonExternals()],
-    devtool: "source-map",
-    module: {
-        rules: [{
-            test: /\.tsx?$/,
-            loader: 'awesome-typescript-loader',
-            options: {
-                configFileName: path.resolve(__dirname, './tsconfig.json'),
-                declaration: false
-            }
-        }]
-    },
-    mode: "production",
-    performance: {
-        hints: false
-    },
-    plugins: [
-        new HardSourceWebpackPlugin(),
-        new webpack.WatchIgnorePlugin([
-            /\.js$/,
-            /\.d\.ts$/
-        ])
-    ]
-}
+var config = babylonWebpackConfig({
+    module: "loaders"
+});
+
+module.exports = config;

+ 6 - 48
materialsLibrary/webpack.config.js

@@ -1,49 +1,7 @@
-const path = require('path');
-const webpack = require('webpack');
-const babylonExternals = require('../Tools/WebpackPlugins/babylonExternals');
-const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const babylonWebpackConfig = require('../Tools/WebpackPlugins/babylonWebpackConfig');
 
-module.exports = {
-    context: path.resolve(__dirname, './src'),
-    entry: {
-        'babylonjs-materials': path.resolve(__dirname, './src/legacy/legacy-grid.ts'),
-    },
-    output: {
-        path: path.resolve(__dirname, '../dist/preview release/materialsLibrary'),
-        filename: 'babylonjs.materials.min.js',
-        libraryTarget: 'umd',
-        library: {
-            root: ["MATERIALS"],
-            amd: "babylonjs-materials",
-            commonjs: "babylonjs-materials"
-        },
-        umdNamedDefine: true
-    },
-    resolve: {
-        extensions: ['.ts']
-    },
-    externals: [babylonExternals()],
-    devtool: "souce-map",
-    module: {
-        rules: [{
-            test: /\.tsx?$/,
-            loader: 'awesome-typescript-loader',
-            options: {
-                configFileName: path.resolve(__dirname, './tsconfig.json'),
-                declaration: false
-            }
-        }]
-    },
-    mode: "production",
-    performance: {
-        hints: false
-    },
-    plugins: [
-        new HardSourceWebpackPlugin(),
-        new webpack.WatchIgnorePlugin([
-            /\.js$/,
-            /\.d\.ts$/,
-            /\.fx$/
-        ])
-    ],
-}
+var config = babylonWebpackConfig({
+    module: "materialsLibrary"
+});
+
+module.exports = config;

+ 6 - 48
postProcessLibrary/webpack.config.js

@@ -1,49 +1,7 @@
-const path = require('path');
-const webpack = require('webpack');
-const babylonExternals = require('../Tools/WebpackPlugins/babylonExternals');
-const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const babylonWebpackConfig = require('../Tools/WebpackPlugins/babylonWebpackConfig');
 
-module.exports = {
-    context: path.resolve(__dirname, './src'),
-    entry: {
-        'babylonjs-postProcessesLibrary': path.resolve(__dirname, './src/legacy/legacy.ts'),
-    },
-    output: {
-        path: path.resolve(__dirname, '../dist/preview release/postProcessLibrary'),
-        filename: 'babylonjs.postProcess.min.js',
-        libraryTarget: 'umd',
-        library: {
-            root: ["POSTPROCESSES"],
-            amd: "babylonjs-postProcessesLibrary",
-            commonjs: "babylonjs-postProcessesLibrary"
-        },
-        umdNamedDefine: true
-    },
-    resolve: {
-        extensions: ['.ts']
-    },
-    externals: [babylonExternals()],
-    devtool: "source-map",
-    module: {
-        rules: [{
-            test: /\.tsx?$/,
-            loader: 'awesome-typescript-loader',
-            options: {
-                configFileName: path.resolve(__dirname, './tsconfig.json'),
-                declaration: false
-            }
-        }]
-    },
-    mode: "production",
-    performance: {
-        hints: false
-    },
-    plugins: [
-        new HardSourceWebpackPlugin(),
-        new webpack.WatchIgnorePlugin([
-            /\.js$/,
-            /\.d\.ts$/,
-            /\.fx$/
-        ])
-    ]
-}
+var config = babylonWebpackConfig({
+    module: "postProcessesLibrary"
+});
+
+module.exports = config;

+ 6 - 48
proceduralTexturesLibrary/webpack.config.js

@@ -1,49 +1,7 @@
-const path = require('path');
-const webpack = require('webpack');
-const babylonExternals = require('../Tools/WebpackPlugins/babylonExternals');
-const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const babylonWebpackConfig = require('../Tools/WebpackPlugins/babylonWebpackConfig');
 
-module.exports = {
-    context: path.resolve(__dirname, './src'),
-    entry: {
-        'babylonjs-procedural-textures': path.resolve(__dirname, './src/legacy/legacy.ts'),
-    },
-    output: {
-        path: path.resolve(__dirname, '../dist/preview release/gui'),
-        filename: 'babylonjs.proceduralTextures.min.js',
-        libraryTarget: 'umd',
-        library: {
-            root: ["PROCEDURALTEXTURES"],
-            amd: "babylonjs-procedural-textures",
-            commonjs: "babylonjs-procedural-textures"
-        },
-        umdNamedDefine: true
-    },
-    resolve: {
-        extensions: ['.ts']
-    },
-    externals: [babylonExternals()],
-    devtool: "source-map",
-    module: {
-        rules: [{
-            test: /\.tsx?$/,
-            loader: 'awesome-typescript-loader',
-            options: {
-                configFileName: path.resolve(__dirname, './tsconfig.json'),
-                declaration: false
-            }
-        }]
-    },
-    mode: "production",
-    performance: {
-        hints: false
-    },
-    plugins: [
-        new HardSourceWebpackPlugin(),
-        new webpack.WatchIgnorePlugin([
-            /\.js$/,
-            /\.d\.ts$/,
-            /\.fx$/
-        ])
-    ]
-}
+var config = babylonWebpackConfig({
+    module: "proceduralTexturesLibrary"
+});
+
+module.exports = config;

+ 6 - 48
serializers/webpack.config.js

@@ -1,49 +1,7 @@
-const path = require('path');
-const webpack = require('webpack');
-const babylonExternals = require('../Tools/WebpackPlugins/babylonExternals');
-const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
+const babylonWebpackConfig = require('../Tools/WebpackPlugins/babylonWebpackConfig');
 
-module.exports = {
-    context: path.resolve(__dirname, './src'),
-    entry: {
-        'babylonjs-loaders': path.resolve(__dirname, './src/legacy/legacy.ts'),
-    },
-    output: {
-        path: path.resolve(__dirname, '../dist/preview release/serializers'),
-        filename: 'babylonjs.serializers.min.js',
-        libraryTarget: 'umd',
-        library: {
-            root: ["SERIALIZERS"],
-            amd: "babylonjs-serializers",
-            commonjs: "babylonjs-serializers"
-        },
-        umdNamedDefine: true
-    },
-    resolve: {
-        extensions: ['.ts']
-    },
-    externals: [babylonExternals()],
-    devtool: "source-map",
-    module: {
-        rules: [{
-            test: /\.tsx?$/,
-            loader: 'awesome-typescript-loader',
-            options: {
-                configFileName: path.resolve(__dirname, './tsconfig.json'),
-                declaration: false
-            }
-        }]
-    },
-    mode: "production",
-    performance: {
-        hints: false
-    },
-    plugins: [
-        new HardSourceWebpackPlugin(),
-        new webpack.WatchIgnorePlugin([
-            /\.js$/,
-            /\.d\.ts$/,
-            /\.fx$/
-        ])
-    ]
-}
+var config = babylonWebpackConfig({
+    module: "serializers"
+});
+
+module.exports = config;