Webpack for production build (#134)

* Webpack config for production build
This commit is contained in:
Cássio Souza 2016-10-21 21:18:45 -02:00 committed by GitHub
parent 1eea94621e
commit 2c8cdfc15e
3 changed files with 61 additions and 4 deletions

View File

@ -7,7 +7,7 @@
"start": "webpack-dev-server --config webpack.dev.js",
"test": "NODE_ENV=test jest",
"test:watch": "NODE_ENV=test jest --watch",
"build": "webpack --config webpack.config.js",
"build": "NODE_ENV=production webpack --config webpack.prod.js",
"storybook": "start-storybook -p 9001",
"storybook-build": "build-storybook -o dist",
"lint": "npm run lint:js & npm run lint:css",
@ -62,6 +62,7 @@
"eslint-config-netlify": "github:netlify/eslint-config-netlify",
"expect": "^1.20.2",
"exports-loader": "^0.6.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"fsevents": "^1.0.14",
"identity-obj-proxy": "^3.0.0",

41
webpack.prod.js Normal file
View File

@ -0,0 +1,41 @@
/* global module, __dirname, require */
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = merge.smart(require('./webpack.base.js'), {
entry: {
cms: [
'./index',
],
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
},
module: {
loaders: [
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css?modules!sass'),
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&&localIdentName=cms__[name]__[local]!postcss'),
},
],
},
context: path.join(__dirname, 'src'),
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin(),
new ExtractTextPlugin('[name].css', { allChunks: true }),
],
});

View File

@ -293,7 +293,7 @@ async@^0.9.0:
version "0.9.2"
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
async@^1.3.0, async@^1.4.0, async@^1.4.2, async@1.x:
async@^1.3.0, async@^1.4.0, async@^1.4.2, async@^1.5.0, async@1.x:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
@ -2884,6 +2884,14 @@ extglob@^0.3.1:
dependencies:
is-extglob "^1.0.0"
extract-text-webpack-plugin:
version "1.0.1"
resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-1.0.1.tgz#c95bf3cbaac49dc96f1dc6e072549fbb654ccd2c"
dependencies:
async "^1.5.0"
loader-utils "^0.2.3"
webpack-sources "^0.1.0"
extsprintf@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550"
@ -4628,7 +4636,7 @@ load-json-file@^1.0.0:
pinkie-promise "^2.0.0"
strip-bom "^2.0.0"
loader-utils@^0.2.11, loader-utils@^0.2.14, loader-utils@^0.2.15, loader-utils@^0.2.7, loader-utils@~0.2.2, loader-utils@~0.2.5, loader-utils@0.2.x:
loader-utils@^0.2.11, loader-utils@^0.2.14, loader-utils@^0.2.15, loader-utils@^0.2.3, loader-utils@^0.2.7, loader-utils@~0.2.2, loader-utils@~0.2.5, loader-utils@0.2.x:
version "0.2.16"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d"
dependencies:
@ -7475,7 +7483,7 @@ source-map@^0.4.2, source-map@^0.4.4, source-map@~0.4.1, source-map@~0.4.2:
dependencies:
amdefine ">=0.0.4"
source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1:
source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1, source-map@~0.5.3:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
@ -8385,6 +8393,13 @@ webpack-postcss-tools@^1.1.1:
postcss "^4.1.7"
resolve "^1.1.6"
webpack-sources@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.1.2.tgz#057a3f3255f8ba561b901d9150589aa103a57e65"
dependencies:
source-list-map "~0.1.0"
source-map "~0.5.3"
webpack@^1.12.11, webpack@^1.13.2:
version "1.13.2"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.13.2.tgz#f11a96f458eb752970a86abe746c0704fabafaf3"