Skip to content

Commit

Permalink
chore: add settings for webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
mori-dev committed Nov 30, 2016
1 parent 4bc1e1e commit cccc60b
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
55 changes: 55 additions & 0 deletions webpack.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const path = require('path');
const webpack = require('webpack');
const FlowStatusWebpackPlugin = require('flow-status-webpack-plugin');

require('dotenv').config();

const config = {
entry: ['./src/index.js'],
output: {
path: path.resolve('www/js/'),
filename: 'bundle.js',
},
module: {
preLoaders: [
{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/,
},
],
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
},
{
test: /\.css$/,
loaders: ['style', 'css?modules'],
},
{
test: /\.json$/,
loader: 'json',
},
],
},
eslint: {
configFile: './.eslintrc.yaml',
fix: true,
},
plugins: [
new webpack.NoErrorsPlugin(),
new FlowStatusWebpackPlugin({
binaryPath: './node_modules/.bin/flow',
failOnError: true,
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
},
}),
],
};

module.exports = config;
20 changes: 20 additions & 0 deletions webpack.config.development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const merge = require('webpack-merge');
const path = require('path');
const WriteFilePlugin = require('write-file-webpack-plugin');
const baseConfig = require('./webpack.config.base.js');

const config = merge.smart(baseConfig, {
devtool: 'inline-source-map',
devServer: {
outputPath: path.join(__dirname, './www/js'),
contentBase: path.join(__dirname, './www'),
port: 8090,
host: '0.0.0.0',
inline: true,
},
plugins: [
new WriteFilePlugin(),
],
});

module.exports = config;
12 changes: 12 additions & 0 deletions webpack.config.production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const path = require('path');
const merge = require('webpack-merge');
const baseConfig = require('./webpack.config.base.js');

const config = merge(baseConfig, {
eslint: {
configFile: './.eslintrc.yaml',
fix: false,
},
});

module.exports = config;

0 comments on commit cccc60b

Please sign in to comment.