Separate webpack configs into prod and dev

This commit is contained in:
pcvonz
2017-09-07 12:54:47 -07:00
parent 5562c1dcde
commit dd4e00178e
8 changed files with 93 additions and 1779 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,20 +1 @@
webpackJsonp([0],[
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__scss_style_scss__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__scss_style_scss___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__scss_style_scss__);
/***/ }),
/* 1 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ })
],[0]);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9zcmMvaW5kZXguanMiLCJ3ZWJwYWNrOi8vLy4vc3JjL3Njc3Mvc3R5bGUuc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7OztBQUFBOzs7Ozs7O0FDQUEseUMiLCJmaWxlIjoibWFpbi4xNzE3NDY2YmMxYjRlYmY2YTIxOC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCAnLi9zY3NzL3N0eWxlLnNjc3MnO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvaW5kZXguanNcbi8vIG1vZHVsZSBpZCA9IDBcbi8vIG1vZHVsZSBjaHVua3MgPSAwIiwiLy8gcmVtb3ZlZCBieSBleHRyYWN0LXRleHQtd2VicGFjay1wbHVnaW5cblxuXG4vLy8vLy8vLy8vLy8vLy8vLy9cbi8vIFdFQlBBQ0sgRk9PVEVSXG4vLyAuL3NyYy9zY3NzL3N0eWxlLnNjc3Ncbi8vIG1vZHVsZSBpZCA9IDFcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sInNvdXJjZVJvb3QiOiIifQ==
webpackJsonp([0],[function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var c=t(1);t.n(c)},function(e,n){}],[0]);

File diff suppressed because one or more lines are too long

View File

@@ -14,13 +14,15 @@
"resolve-url-loader": "^2.1.0",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"uglifyjs-webpack-plugin": "^0.4.6",
"webpack": "^3.5.5",
"webpack-dev-middleware": "^1.12.0",
"webpack-dev-server": "^2.7.1"
"webpack-dev-server": "^2.7.1",
"webpack-merge": "^4.1.0"
},
"dependencies": {},
"scripts": {
"build": "webpack",
"build": "webpack --config webpack.prod.js",
"watch": "webpack --watch"
}
}

View File

@@ -0,0 +1,57 @@
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: './src/index.js',
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, './assets/packed'),
publicPath: ''
},
// TODO: Change to something faster in the future
devtool: 'inline-source-map',
// TODO: Add webpack-dev-server
plugins: [
new CleanWebpackPlugin(['./assets/packed']),
new webpack.optimize.CommonsChunkPlugin({
name: 'common' // Specify the bundle name
}),
new ExtractTextPlugin('style.css')
],
// TODO: Minimize css/js
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader', options: {
sourceMap: true,
minimize: true
}
},{
loader: 'postcss-loader', options: {
sourceMap: true
}
},{
loader: 'sass-loader', options: {
sourceMap: true
},
}],
// use style loader in development
fallback: 'style-loader'
})
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
}
]
}
};

View File

@@ -0,0 +1,6 @@
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common,
devtool: 'inline-source-map',
});

View File

@@ -0,0 +1,16 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const common = require('./webpack.common.js');
module.exports = merge(common, {
plugins: [
new UglifyJSPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
]
});

View File

@@ -3840,6 +3840,12 @@ webpack-dev-server@^2.7.1:
webpack-dev-middleware "^1.11.0"
yargs "^6.0.0"
webpack-merge@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.0.tgz#6ad72223b3e0b837e531e4597c199f909361511e"
dependencies:
lodash "^4.17.4"
webpack-sources@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf"