From c55adb13d9b5ec13c2494e0045967aceb5a57f8f Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 15 Oct 2016 12:16:42 -0400 Subject: [PATCH] Initial webpack config with JS build support --- lib/canopy-loader.js | 6 ++++++ package.json | 8 ++++++-- webpack.config.js | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 lib/canopy-loader.js create mode 100644 webpack.config.js diff --git a/lib/canopy-loader.js b/lib/canopy-loader.js new file mode 100644 index 0000000..511506d --- /dev/null +++ b/lib/canopy-loader.js @@ -0,0 +1,6 @@ +var canopy = require('canopy'); + +module.exports = function(source) { + this.cacheable(); + return canopy.compile(source); +}; diff --git a/package.json b/package.json index 6576503..d5291a4 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,10 @@ "license": "MIT", "private": true, "devDependencies": { + "babel-core": "^6.17.0", + "babel-loader": "^6.2.5", "babel-polyfill": "^6.3.14", - "babel-preset-es2015": "^6.3.13", + "babel-preset-es2015": "^6.16.0", "babel-runtime": "^6.3.19", "babelify": "^7.1.0", "browserify": "^13.0.0", @@ -30,6 +32,7 @@ "gulp-sourcemaps": "^1.6.0", "gulp-uglify": "^1.4.2", "handlebars-layouts": "^3.1.2", + "imports-loader": "^0.6.5", "jasmine-core": "^2.4.1", "karma": "^1.1.2", "karma-browserify": "^5.0.2", @@ -42,6 +45,7 @@ "through": "^2.3.8", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", - "watchify": "^3.7.0" + "watchify": "^3.7.0", + "webpack": "^1.13.2" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..6ff848f --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,36 @@ +var webpack = require('webpack'); + +module.exports = { + devtool: 'source-map', + entry: { + 'js/main.js': './src/js/main.js' + }, + output: { + path: __dirname + '/build', + filename: '[name]' + }, + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + } + }) + ], + module: { + loaders: [ + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel' + }, + { + test: require.resolve('snapsvg'), + loader: 'imports-loader?this=>window,fix=>module.exports=0' + }, + { + test: /\.peg$/, + loader: __dirname + '/lib/canopy-loader' + } + ] + } +};