{"action":"created","issue":{"url":"https://api.github.com/repos/lean/phaser-es6-webpack/issues/68","repository_url":"https://api.github.com/repos/lean/phaser-es6-webpack","labels_url":"https://api.github.com/repos/lean/phaser-es6-webpack/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/lean/phaser-es6-webpack/issues/68/comments","events_url":"https://api.github.com/repos/lean/phaser-es6-webpack/issues/68/events","html_url":"https://github.com/lean/phaser-es6-webpack/issues/68","id":316965768,"number":68,"title":"Importing Box2D?","user":{"login":"tahagabre","id":38015574,"avatar_url":"https://avatars1.githubusercontent.com/u/38015574?v=4","gravatar_id":"","url":"https://api.github.com/users/tahagabre","html_url":"https://github.com/tahagabre","followers_url":"https://api.github.com/users/tahagabre/followers","following_url":"https://api.github.com/users/tahagabre/following{/other_user}","gists_url":"https://api.github.com/users/tahagabre/gists{/gist_id}","starred_url":"https://api.github.com/users/tahagabre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tahagabre/subscriptions","organizations_url":"https://api.github.com/users/tahagabre/orgs","repos_url":"https://api.github.com/users/tahagabre/repos","events_url":"https://api.github.com/users/tahagabre/events{/privacy}","received_events_url":"https://api.github.com/users/tahagabre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-04-23T20:13:09Z","updated_at":"2018-04-27T13:38:43Z","closed_at":null,"author_association":"NONE","body":"I want to figure out how to import the Box2D plug-in into my Phaser project with this template. I threw box2d.js into /node_modules/phaser-ce/build/custom and adjusted the Webpack configuration.\r\n\r\nMy current set up is as follows:\r\n<br>\r\n\r\nmain.js:\r\n```\r\nimport 'pixi'\r\nimport 'p2'\r\nimport 'box2d'\r\nimport Phaser from 'phaser'\r\n```\r\n\r\nwebpack.config.js:\r\n```\r\n    var path = require('path')\r\n    var webpack = require('webpack')\r\n    var HtmlWebpackPlugin = require('html-webpack-plugin')\r\n    var BrowserSyncPlugin = require('browser-sync-webpack-plugin')\r\n    \r\n    // Phaser webpack config\r\n    var phaserModule = path.join(__dirname, '/node_modules/phaser-ce/')\r\n    var phaser = path.join(phaserModule, 'build/custom/phaser-split.js')\r\n    var pixi = path.join(phaserModule, 'build/custom/pixi.js')\r\n    var p2 = path.join(phaserModule, 'build/custom/p2.js')\r\n    var box2d = path.join(phaserModule, 'build/custom/box2D.js')\r\n    \r\n    var definePlugin = new webpack.DefinePlugin({\r\n      __DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true'))\r\n    })\r\n    \r\n    module.exports = {\r\n      entry: {\r\n        app: [\r\n          'babel-polyfill',\r\n          path.resolve(__dirname, 'src/main.js')\r\n        ],\r\n        vendor: ['pixi', 'p2', 'phaser', 'box2d', 'webfontloader']\r\n      },\r\n      devtool: 'cheap-source-map',\r\n      output: {\r\n        pathinfo: true,\r\n        path: path.resolve(__dirname, 'dist'),\r\n        publicPath: './dist/',\r\n        filename: 'bundle.js'\r\n      },\r\n      watch: true,\r\n      plugins: [\r\n        definePlugin,\r\n        new webpack.optimize.CommonsChunkPlugin({ name: 'vendor'/* chunkName= */, filename: 'vendor.bundle.js'/* filename= */}),\r\n        new HtmlWebpackPlugin({\r\n          filename: '../index.html',\r\n          template: './src/index.html',\r\n          chunks: ['vendor', 'app'],\r\n          chunksSortMode: 'manual',\r\n          minify: {\r\n            removeAttributeQuotes: false,\r\n            collapseWhitespace: false,\r\n            html5: false,\r\n            minifyCSS: false,\r\n            minifyJS: false,\r\n            minifyURLs: false,\r\n            removeComments: false,\r\n            removeEmptyAttributes: false\r\n          },\r\n          hash: false\r\n        }),\r\n        new BrowserSyncPlugin({\r\n          host: process.env.IP || 'localhost',\r\n          port: process.env.PORT || 3000,\r\n          server: {\r\n            baseDir: ['./', './build']\r\n          }\r\n        })\r\n      ],\r\n      module: {\r\n        rules: [\r\n          { test: /\\.js$/, use: ['babel-loader'], include: path.join(__dirname, 'src') },\r\n          { test: /pixi\\.js/, use: ['expose-loader?PIXI'] },\r\n          { test: /phaser-split\\.js$/, use: ['expose-loader?Phaser'] },\r\n          { test: /p2\\.js/, use: ['expose-loader?p2'] },\r\n          { test: /box2D\\.js/, use: ['expose-loader?box2d'] }\r\n        ]\r\n      },\r\n      node: {\r\n        fs: 'empty',\r\n        net: 'empty',\r\n        tls: 'empty'\r\n      },\r\n      resolve: {\r\n        alias: {\r\n          'phaser': phaser,\r\n          'pixi': pixi,\r\n          'p2': p2,\r\n          'box2d': box2d\r\n        }\r\n      }\r\n    }\r\n```\r\n\r\nWhen I run the app, I get a 'Uncaught ReferenceError: box2d is not defined' in my console. The line in reference is the second line of box2D.js.\r\n\r\nSimply throwing the file in a `<script>` tag in index.html works, but it is sloppy and not preferred. \r\n\r\nAny suggestions to using a modular Box2D with this template?"},"comment":{"url":"https://api.github.com/repos/lean/phaser-es6-webpack/issues/comments/384972552","html_url":"https://github.com/lean/phaser-es6-webpack/issues/68#issuecomment-384972552","issue_url":"https://api.github.com/repos/lean/phaser-es6-webpack/issues/68","id":384972552,"user":{"login":"dywedir","id":399312,"avatar_url":"https://avatars0.githubusercontent.com/u/399312?v=4","gravatar_id":"","url":"https://api.github.com/users/dywedir","html_url":"https://github.com/dywedir","followers_url":"https://api.github.com/users/dywedir/followers","following_url":"https://api.github.com/users/dywedir/following{/other_user}","gists_url":"https://api.github.com/users/dywedir/gists{/gist_id}","starred_url":"https://api.github.com/users/dywedir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dywedir/subscriptions","organizations_url":"https://api.github.com/users/dywedir/orgs","repos_url":"https://api.github.com/users/dywedir/repos","events_url":"https://api.github.com/users/dywedir/events{/privacy}","received_events_url":"https://api.github.com/users/dywedir/received_events","type":"User","site_admin":false},"created_at":"2018-04-27T13:38:43Z","updated_at":"2018-04-27T13:38:43Z","author_association":"NONE","body":"Hm.. maybe \r\n```\r\nimport 'box2d'\r\n```\r\nshould go after `Phaser` import?"}}
{"actor":{"display_login":"dywedir"}}