var path = require('path'); var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var BrowserSyncPlugin = require('browser-sync-webpack-plugin'); // var CopyWebpackPlugin = require('copy-webpack-plugin'); var { CleanWebpackPlugin } = require('clean-webpack-plugin'); var definePlugin = new webpack.DefinePlugin({ 'process.env.DEV': JSON.stringify(JSON.parse(process.env.DEV || 'false')), 'process.env.SERVER_URL': JSON.stringify(process.env.SERVER_URL || 'http://109.214.245.153'), 'process.env.SERVER_PORT': JSON.stringify(process.env.SERVER_PORT || '2610') }); var outpath = './webpack/'; if (!process.env.DEV || process.env.DEV === false) { console.log('CORDOVA environment'); outpath = 'www/'; } else { console.log('DEV environment'); } // new CopyWebpackPlugin([ // { // context: path.resolve(__dirname, 'src', 'assets'), // from: '**/*', // to: path.resolve(__dirname, outpath, 'assets') // } // ]), module.exports = { devtool: 'cheap-source-map', mode: 'development', entry: { app: path.resolve(__dirname, 'src/main.js') }, output: { filename: 'app.bundle.js', path: path.resolve(__dirname, outpath) }, plugins: [ definePlugin, new CleanWebpackPlugin(), new HtmlWebpackPlugin({ template: './src/index.html' }), new BrowserSyncPlugin({ host: process.env.IP || 'localhost', port: process.env.PORT || 3000, server: { baseDir: [outpath, './build'] }, browser: ["firefox"] }), new BrowserSyncPlugin({ host: process.env.IP || 'localhost', port: process.env.PORT || 3005, server: { baseDir: [outpath, './build'] }, browser: ["firefox"] }), new webpack.DefinePlugin({ CANVAS_RENDERER: JSON.stringify(true), WEBGL_RENDERER: JSON.stringify(true) }) ], module: { rules: [ { test: /\.js$/, exclude: /(node_modules|server)/, loaders: "babel-loader" }, { test: /\.(png|svg|jpg|gif)$/, use: { loader: 'file-loader', options: { esModule: false } } }, { test: /\.html$/, exclude: /index.html/, use: [ { loader: 'html-loader', options: { minimize: true } } ] }, { test: [/\.vert$/, /\.frag$/], use: "raw-loader" } ] } };