Added own configuration objects for different webpack environments.

This commit is contained in:
Chris
2015-09-17 08:02:36 +02:00
parent 22be5fe0f4
commit f871f2aef7
10 changed files with 207 additions and 155 deletions
+68
View File
@@ -0,0 +1,68 @@
var path = require('path');
var port = 8000;
var srcPath = path.join(__dirname, '/../src');
var publicPath = '/assets/';
module.exports = {
port: port,
debug: true,
output: {
path: path.join(__dirname, '/../dist/assets'),
filename: 'app.js',
publicPath: publicPath
},
devServer: {
contentBase: './src/',
historyApiFallback: true,
hot: true,
port: port,
publicPath: publicPath,
noInfo: false
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
actions: srcPath + '/actions/',
components: srcPath + '/components/',
sources: srcPath + '/sources/',
stores: srcPath + '/stores/',
styles: srcPath + '/styles/'
}
},
module: {
preLoaders: [
{
test: /\.(js|jsx)$/,
include: path.join(__dirname, 'src'),
loader: 'eslint-loader'
}
],
loaders: [
{
test: /\.css$/,
loader: 'style!css'
},
{
test: /\.sass/,
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax'
},
{
test: /\.scss/,
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded'
},
{
test: /\.less/,
loader: 'style-loader!css-loader!less-loader'
},
{
test: /\.styl/,
loader: 'style-loader!css-loader!stylus-loader'
},
{
test: /\.(png|jpg|gif|woff|woff2)$/,
loader: 'url-loader?limit=8192'
}
]
}
};
+28
View File
@@ -0,0 +1,28 @@
var path = require('path');
var webpack = require('webpack');
var _ = require('lodash');
var baseConfig = require('./base');
var config = _.merge({
entry: [
'webpack-dev-server/client?http://127.0.0.1:8000',
'webpack/hot/only-dev-server',
'./src/components/run'
],
cache: true,
devtool: 'eval',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
}, baseConfig);
// Add needed loaders
config.module.loaders.push({
test: /\.(js|jsx)$/,
loader: 'react-hot!babel-loader',
include: path.join(__dirname, '/../src')
});
module.exports = config;
+26
View File
@@ -0,0 +1,26 @@
var path = require('path');
var webpack = require('webpack');
var _ = require('lodash');
var baseConfig = require('./base');
var config = _.merge({
entry: path.join(__dirname, '../src/components/run'),
cache: false,
devtool: 'sourcemap',
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.NoErrorsPlugin()
]
}, baseConfig);
config.module.loaders.push({
test: /\.(js|jsx)$/,
loader: 'babel',
include: path.join(__dirname, '/../src')
});
module.exports = config;
+33
View File
@@ -0,0 +1,33 @@
var path = require('path');
var srcPath = path.join(__dirname, '/../src/');
module.exports = {
devtool: 'eval',
module: {
loaders: [
{
test: /\.(png|jpg|gif|woff|woff2|css|sass|scss|less|styl)$/,
loader: 'null-loader'
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
include: [
path.join(__dirname, '/../src'),
path.join(__dirname, '/../test')
]
}
]
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
actions: srcPath + 'actions/',
helpers: path.join(__dirname, '/../test/helpers'),
components: srcPath + 'components/',
sources: srcPath + 'sources/',
stores: srcPath + 'stores/',
styles: srcPath + 'styles/'
}
}
};