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')) }); var outpath = './webpack/'; if (!process.env.DEV || process.env.DEV === false) { console.log('CORDOVA environment'); outpath = 'www/'; } else { console.log('DEV environment'); } module.exports = { devtool: 'eval-source-map', mode: 'development', entry: { app: path.resolve(__dirname, 'src/main.js') }, target: 'web', watch: true, output: { filename: 'app.bundle.js', path: path.resolve(__dirname, outpath + 'dist') }, plugins: [ definePlugin, new CleanWebpackPlugin(), new CopyWebpackPlugin([ { context: path.resolve(__dirname, 'src', 'assets'), from: '**/*', to: path.resolve(__dirname, outpath, 'assets') } ]), new HtmlWebpackPlugin({ filename: '../index.html', template: './src/index.html', minify: { removeAttributeQuotes: false, collapseWhitespace: false, html5: false, minifyCSS: false, minifyJS: false, minifyURLs: false, removeComments: false, removeEmptyAttributes: false }, hash: false, inject: true }), 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: /\.(gif|png|jpe?g|svg|xml)$/i, use: "file-loader" }, { test: [/\.vert$/, /\.frag$/], use: "raw-loader" } ] } };