From 152e4129b2b13076aa7deddb6368485ca60f9a7c Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Fri, 25 Dec 2015 04:58:39 +0900 Subject: [PATCH] cleanup webpack config --- webpack-production.config.js | 7 ---- webpack.config.js | 68 +++++++++--------------------- webpack.config.production.js | 80 ------------------------------------ 3 files changed, 19 insertions(+), 136 deletions(-) delete mode 100644 webpack.config.production.js diff --git a/webpack-production.config.js b/webpack-production.config.js index bda33a25..7f673ec9 100644 --- a/webpack-production.config.js +++ b/webpack-production.config.js @@ -45,11 +45,4 @@ var config = Object.assign({}, skeleton, { ] }) -config.target = function renderer (compiler) { - compiler.apply( - new JsonpTemplatePlugin(config.output), - new FunctionModulePlugin(config.output) - ) -} - module.exports = config diff --git a/webpack.config.js b/webpack.config.js index 7b279fdc..29c5ddc9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,24 +1,16 @@ -var webpack = require('webpack') -var path = require('path') -var JsonpTemplatePlugin = webpack.JsonpTemplatePlugin -var FunctionModulePlugin = require('webpack/lib/FunctionModulePlugin') -var NodeTargetPlugin = require('webpack/lib/node/NodeTargetPlugin') +const skeleton = require('./webpack-skeleton') +const webpack = require('webpack') +const path = require('path') +const JsonpTemplatePlugin = webpack.JsonpTemplatePlugin +const FunctionModulePlugin = require('webpack/lib/FunctionModulePlugin') -var opt = { - path: path.join(__dirname, 'compiled'), - filename: '[name].js', - sourceMapFilename: '[name].map', - libraryTarget: 'commonjs2', - publicPath: 'http://localhost:8080/assets/' -} - -var config = { +var config = Object.assign({}, skeleton, { module: { loaders: [ { test: /\.js?$/, - loader: 'babel-loader?cacheDirectory', - exclude: /node_modules/ + exclude: /node_modules/, + loader: 'babel?cacheDirectory' }, { test: /\.styl?$/, @@ -27,43 +19,21 @@ var config = { } ] }, + output: { + path: path.join(__dirname, 'compiled'), + filename: '[name].js', + sourceMapFilename: '[name].map', + libraryTarget: 'commonjs2', + publicPath: 'http://localhost:8080/assets/' + }, debug: true, - devtool: 'eval-source-map', - entry: { - main: './browser/main/index.js', - finder: './browser/finder/index.js' - }, - output: opt, - resolve: { - extensions: ['', '.js', '.jsx'], - packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'], - alias: { - 'boost': path.resolve(__dirname, 'lib') - } - }, - plugins: [ - new webpack.NoErrorsPlugin(), - new NodeTargetPlugin() - ], - externals: [ - 'electron', - 'socket.io-client', - 'md5', - 'superagent', - 'superagent-promise', - 'lodash', - 'markdown-it', - 'moment', - 'highlight.js', - 'markdown-it-emoji', - 'fs-jetpack' - ] -} + devtool: 'eval-source-map' +}) config.target = function renderer (compiler) { compiler.apply( - new JsonpTemplatePlugin(opt), - new FunctionModulePlugin(opt) + new JsonpTemplatePlugin(config.output), + new FunctionModulePlugin(config.output) ) } diff --git a/webpack.config.production.js b/webpack.config.production.js deleted file mode 100644 index 2f4f8b68..00000000 --- a/webpack.config.production.js +++ /dev/null @@ -1,80 +0,0 @@ -var webpack = require('webpack') -var path = require('path') -var JsonpTemplatePlugin = webpack.JsonpTemplatePlugin -var FunctionModulePlugin = require('webpack/lib/FunctionModulePlugin') -var NodeTargetPlugin = require('webpack/lib/node/NodeTargetPlugin') - -var opt = { - path: path.join(__dirname, 'compiled'), - filename: '[name].js', - sourceMapFilename: '[name].map', - libraryTarget: 'commonjs2', - publicPath: 'http://localhost:8080/assets/' -} - -var config = { - module: { - loaders: [ - { - test: /(\.js|\.jsx)?$/, - exclude: /(node_modules|bower_components)/, - loader: 'babel' - }, - { - test: /\.styl?$/, - exclude: /(node_modules|bower_components)/, - loader: 'style-loader!css-loader!stylus-loader' - } - ] - }, - entry: { - main: './browser/main/index.js', - finder: './browser/finder/index.js' - }, - output: opt, - resolve: { - extensions: ['', '.js', '.jsx'], - packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'], - alias: { - 'boost': path.resolve(__dirname, 'lib') - } - }, - plugins: [ - new webpack.NoErrorsPlugin(), - new NodeTargetPlugin(), - new webpack.optimize.OccurenceOrderPlugin(), - new webpack.DefinePlugin({ - 'process.env': { - 'NODE_ENV': JSON.stringify('production'), - 'BABEL_ENV': JSON.stringify('production') - } - }), - new webpack.optimize.UglifyJsPlugin({ - compressor: { - warnings: false - } - }) - ], - externals: [ - 'electron', - 'socket.io-client', - 'md5', - 'superagent', - 'superagent-promise', - 'lodash', - 'markdown-it', - 'moment', - 'highlight.js', - 'markdown-it-emoji', - 'fs-jetpack' - ] -} - -config.target = function renderer (compiler) { - compiler.apply( - new JsonpTemplatePlugin(opt), - new FunctionModulePlugin(opt) - ) -} - -module.exports = config