From e6896647331ffdfb6464fcbf2d4e91d9b8206c43 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Tue, 20 Sep 2016 15:52:35 -0400 Subject: [PATCH] Build the module to be imported This puts the details of the loaders needed to build index.js out of the concern of the packages that require it. --- .gitignore | 1 + package.json | 15 ++++++++------- webpack.config.js | 31 ++++++++++++++++++++++--------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index db98532d..4c132982 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ npm-* # Testing /.nyc_output /coverage +/dist.js diff --git a/package.json b/package.json index 33d5ab25..0511ebe0 100644 --- a/package.json +++ b/package.json @@ -9,25 +9,26 @@ "type": "git", "url": "git+ssh://git@github.com/LLK/scratch-vm.git" }, - "main": "./src/index.js", + "main": "./dist.js", "scripts": { - "test": "make test", - "start": "webpack-dev-server --host 0.0.0.0 --content-base ." + "postinstall": "./node_modules/.bin/webpack", + "start": "webpack-dev-server --host 0.0.0.0 --content-base .", + "test": "make test" }, "dependencies": { + "expose-loader": "0.7.1", "htmlparser2": "3.9.0", - "promise": "7.1.1" + "json-loader": "0.5.4", + "promise": "7.1.1", + "webpack": "1.13.0" }, "devDependencies": { "eslint": "2.7.0", - "expose-loader": "0.7.1", "highlightjs": "8.7.0", - "json-loader": "0.5.4", "scratch-blocks": "git+https://git@github.com/LLK/scratch-blocks.git#develop", "scratch-render": "git+https://git@github.com/LLK/scratch-render.git#develop", "stats.js": "0.16.0", "tap": "5.7.1", - "webpack": "1.13.0", "webpack-dev-server": "1.14.1" } } diff --git a/webpack.config.js b/webpack.config.js index 9f80fb08..376ccd25 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,14 +1,6 @@ var webpack = require('webpack'); -module.exports = { - entry: { - 'vm': './src/index.js', - 'vm.min': './src/index.js' - }, - output: { - path: __dirname, - filename: '[name].js' - }, +var base = { module: { loaders: [ { @@ -30,3 +22,24 @@ module.exports = { }) ] }; + +module.exports = [Object.assign({}, base, { + entry: { + 'vm': './src/index.js', + 'vm.min': './src/index.js' + }, + output: { + path: __dirname, + filename: '[name].js' + } +}), Object.assign({}, base, { + entry: { + 'dist': './src/index.js' + }, + output: { + library: 'VirtualMachine', + libraryTarget: 'commonjs2', + path: __dirname, + filename: '[name].js' + } +})];