|
@@ -0,0 +1,76 @@
|
|
|
+var path = require('path');
|
|
|
+var webpack = require('webpack');
|
|
|
+var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
+var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
|
|
|
+
|
|
|
+var definePlugin = new webpack.DefinePlugin({
|
|
|
+ __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true'))
|
|
|
+});
|
|
|
+
|
|
|
+module.exports = {
|
|
|
+ devtool: 'cheap-source-map',
|
|
|
+ mode: 'development',
|
|
|
+ entry: {
|
|
|
+ polyfills: './src/polyfills.js',
|
|
|
+ app: path.resolve(__dirname, 'src/main.js'),
|
|
|
+ },
|
|
|
+ target: 'web',
|
|
|
+ watch: true,
|
|
|
+ output: {
|
|
|
+ pathinfo: true,
|
|
|
+ filename: '[name].bundle.js',
|
|
|
+ chunkFilename: '[name].bundle.js',
|
|
|
+ path: path.resolve(__dirname, 'dist')
|
|
|
+ },
|
|
|
+ optimization: {
|
|
|
+ splitChunks: {
|
|
|
+ cacheGroups: {
|
|
|
+ commons: { test: /[\\/]node_modules[\\/]/, name: "vendors", chunks: "all" }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ plugins: [
|
|
|
+ definePlugin,
|
|
|
+ new HtmlWebpackPlugin({
|
|
|
+ filename: '../index.html',
|
|
|
+ template: './src/index.html',
|
|
|
+ chunksSortMode: "manual",
|
|
|
+ chunks: ['polyfills', 'vendors', 'app'],
|
|
|
+ minify: {
|
|
|
+ removeAttributeQuotes: false,
|
|
|
+ collapseWhitespace: false,
|
|
|
+ html5: false,
|
|
|
+ minifyCSS: false,
|
|
|
+ minifyJS: false,
|
|
|
+ minifyURLs: false,
|
|
|
+ removeComments: false,
|
|
|
+ removeEmptyAttributes: false
|
|
|
+ },
|
|
|
+ hash: false
|
|
|
+ }),
|
|
|
+ new BrowserSyncPlugin({
|
|
|
+ host: process.env.IP || 'localhost',
|
|
|
+ port: process.env.PORT || 3000,
|
|
|
+ server: {
|
|
|
+ baseDir: ['./', './build']
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ new webpack.DefinePlugin({
|
|
|
+ CANVAS_RENDERER: JSON.stringify(true),
|
|
|
+ WEBGL_RENDERER: JSON.stringify(true)
|
|
|
+ })
|
|
|
+ ],
|
|
|
+ module: {
|
|
|
+ rules: [
|
|
|
+ { test: /\.js$/, exclude: /node_modules/, loaders: "babel-loader" },
|
|
|
+ {
|
|
|
+ test: /\.(gif|png|jpe?g|svg|xml)$/i,
|
|
|
+ use: "file-loader"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ test: [/\.vert$/, /\.frag$/],
|
|
|
+ use: "raw-loader"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+};
|