Skip to content

Instantly share code, notes, and snippets.

@vincent178
Created February 13, 2017 06:37
Show Gist options
  • Save vincent178/3f9bead7301df751a84c2e4db23a1424 to your computer and use it in GitHub Desktop.
Save vincent178/3f9bead7301df751a84c2e4db23a1424 to your computer and use it in GitHub Desktop.
webpack
import * as webpack from "webpack";
import * as ExtractTextPlugin from "extract-text-webpack-plugin";
import * as ManifestPlugin from "webpack-manifest-plugin";
import {TypedContext} from "../server/TypedContext";
const css = new ExtractTextPlugin(TypedContext.isProduction() ? "[name].[contenthash].css" : "[name].css");
const manifest = new ManifestPlugin({
writeToFileEmit: true
});
const env = new webpack.DefinePlugin({
'process.env.NODE_ENV': TypedContext.env
});
module.exports = {
target: 'web',
cache: TypedContext.isProduction(),
entry: {
},
output: {
path: `${TypedContext.publicDir}/assets/`,
publicPath: '/assets/',
filename: TypedContext.isProduction() ? '[name].[chunkhash].js' : '[name].js'
},
module: {
loaders: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!sass-loader' })
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader?presets[]=es2015'
},
{
test: /\.(woff|woff2|eot|ttf|svg)(\?.*$|$)/,
loader: 'url'
}
]
},
plugins: [env, css, manifest]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment