Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created November 3, 2015 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save liondancer/f6eb6deac218f8d2ba49 to your computer and use it in GitHub Desktop.
Save liondancer/f6eb6deac218f8d2ba49 to your computer and use it in GitHub Desktop.
var path = require('path');
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: [
'./app/index.js'
],
output: {
path: path.resolve('./public/bundle/'),
filename: 'main.js',
publicPath: 'http://localhost:3000/public/bundle/'
},
plugins: [
new BundleTracker({filename: './webpack-stats.json'}),
new ExtractTextPlugin("style.css", {
allChunks: true
})
],
module: {
loaders: [
{ test: /\.css$/, exclude: /node_modules/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.jsx$/, loaders: ['jsx-loader'], include: path.join(__dirname, 'app') },
{ test: /\.es6$/, exclude: /node_modules/, loader: 'babel-loader?stage=0&optional=runtime'},
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?stage=0&optional=runtime'},
{ test: /\.scss$/, exclude: /node_modules/, loaders: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader') }
]
},
}
var path = require('path');
var config = require("./webpack.config.js");
var Webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var port = process.env.WEBPACK_PORT || 3000;
var host = process.env.HOST || 'localhost';
config.entry.unshift(
"webpack-dev-server/client?http://" + host + ":" + port,
"webpack/hot/only-dev-server" // only prevents reload on syntax errors
);
config.plugins = [
new Webpack.HotModuleReplacementPlugin(),
new Webpack.NoErrorsPlugin(), // don't reload if there is an error
new ExtractTextPlugin("style.css", {
allChunks: true
})
];
config.module.loaders = [
{ test: /\.css$/, exclude: /node_modules/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.jsx$/, loaders: ['react-hot', 'jsx-loader'], include: path.join(__dirname, 'app') },
{ test: /\.es6$/, exclude: /node_modules/, loader: 'babel-loader?stage=0&optional=runtime'},
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?stage=0&optional=runtime'},
// For build
{ test: /\.scss$/, exclude: /node_modules/, loaders: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader') }
// For hot reload
// { test: /\.scss$/, exclude: /node_modules/, loaders: ["style", "css", "sass"]}
];
config.devServer = {
publicPath: config.output.publicPath,
filename: 'main.js',
contentBase: './public',
hot: true,
inline: true,
lazy: false,
quiet: true,
noInfo: true,
headers: {"Access-Control-Allow-Origin": "*"},
stats: {colors: true},
host: "0.0.0.0",
port: port
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment