silverstripe-webpack/webpack.config.dev.js

114 lines
3.2 KiB
JavaScript
Raw Normal View History

2018-02-22 14:39:58 +01:00
/*
* Development assets generation
*/
const path = require("path");
2018-02-05 12:11:01 +01:00
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.config.common.js');
const conf = require('./webpack.configuration');
const IP = process.env.IP || conf.HOSTNAME;
const PORT = process.env.PORT || conf.PORT;
const config = merge.strategy({
entry: 'prepend'
})(common, {
entry: {
app: [
'react-hot-loader/patch',
2018-04-21 05:36:06 +02:00
'webpack-dev-server/client?https://' + conf.HOSTNAME + ':' + conf.PORT,
2018-02-05 12:11:01 +01:00
'webpack/hot/only-dev-server',
2018-02-22 14:39:58 +01:00
]
2018-02-05 12:11:01 +01:00
},
output: {
2018-04-21 05:36:06 +02:00
path: path.join(__dirname, conf.DIST),
2018-02-05 12:11:01 +01:00
filename: '[name].js',
// necessary for HMR to know where to load the hot update chunks
2018-02-22 14:39:58 +01:00
publicPath: 'https://' + conf.HOSTNAME + ':' + conf.PORT + '/'
2018-02-05 12:11:01 +01:00
},
module: {
rules: [{
test: /\.scss$/,
use: [{
loader: 'style-loader',
options: {
sourceMap: true
}
}, {
loader: 'css-loader',
options: {
sourceMap: true
}
}, {
loader: 'postcss-loader',
options: {
sourceMap: true,
plugins: [
autoprefixer({
// If we want to use the same browser list for more tools
// this list should be moved to package.json
// https://evilmartians.com/chronicles/autoprefixer-7-browserslist-2-released
browsers: [
'ie >= 11',
'ie_mob >= 11',
'Safari >= 10',
'Android >= 4.4',
'Chrome >= 44', // Retail
'Samsung >= 4'
]
2018-02-22 14:39:58 +01:00
})
2018-02-05 12:11:01 +01:00
]
}
2018-04-21 05:36:06 +02:00
}, {
loader: 'resolve-url-loader'
2018-02-05 12:11:01 +01:00
}, {
loader: 'sass-loader',
options: {
sourceMap: true
}
}, ]
2018-02-08 19:16:34 +01:00
}, {
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [{
loader: 'url-loader'
}]
2018-04-21 05:36:06 +02:00
}, {
test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|woff(2)?)$/,
use: [{
loader: 'url-loader'
}]
2018-02-22 14:39:58 +01:00
}]
2018-02-05 12:11:01 +01:00
},
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
],
devServer: {
host: IP,
port: PORT,
historyApiFallback: true,
2018-02-22 14:39:58 +01:00
hot: false,
2018-04-21 05:36:06 +02:00
clientLogLevel: 'info',
contentBase: [
path.resolve(__dirname, 'public'),
'node_modules'
],
2018-02-22 14:39:58 +01:00
//watchContentBase: true,
2018-02-05 12:11:01 +01:00
overlay: {
warnings: true,
errors: true
},
headers: {
'Access-Control-Allow-Origin': '*'
}
},
});
module.exports = config;