silverstripe-webpack/webpack4/webpack.config.dev.js

129 lines
3.1 KiB
JavaScript
Raw Normal View History

2018-02-22 14:39:58 +01:00
/*
* Development assets generation
*/
2020-02-12 21:31:59 +01:00
const path = require('path');
2020-08-14 00:36:26 +02:00
//const autoprefixer = require('autoprefixer');
2018-02-05 12:11:01 +01:00
const webpack = require('webpack');
const { merge } = require('webpack-merge');
2018-02-05 12:11:01 +01:00
const common = require('./webpack.config.common.js');
2019-05-23 13:02:32 +02:00
const commonVariables = require('./webpack.configuration');
const conf = commonVariables.configuration;
2018-02-05 12:11:01 +01:00
const IP = process.env.IP || conf.HOSTNAME;
const PORT = process.env.PORT || conf.PORT;
2020-09-10 20:42:55 +02:00
2020-09-10 02:53:21 +02:00
const UIInfo = require('./node_modules/@a2nt/ss-bootstrap-ui-webpack-boilerplate/package.json');
2020-09-10 20:42:55 +02:00
const UIMetaInfo = require('./node_modules/@a2nt/meta-lightbox/package.json');
2018-02-05 12:11:01 +01:00
const config = merge(common, {
2019-06-08 17:54:43 +02:00
mode: 'development',
2018-02-05 12:11:01 +01:00
2019-06-08 17:54:43 +02:00
entry: {
hot: [
2019-06-08 17:54:43 +02:00
'react-hot-loader/patch',
'webpack-dev-server/client?https://' + conf.HOSTNAME + ':' + conf.PORT,
'webpack/hot/only-dev-server',
2020-02-12 21:31:59 +01:00
],
2019-06-08 17:54:43 +02:00
},
2018-02-05 12:11:01 +01:00
2019-06-08 17:54:43 +02:00
output: {
path: path.join(__dirname),
filename: '[name].js',
// necessary for HMR to know where to load the hot update chunks
2020-02-12 21:31:59 +01:00
publicPath: 'https://' + conf.HOSTNAME + ':' + conf.PORT + '/',
2019-06-08 17:54:43 +02:00
},
2018-02-05 12:11:01 +01:00
2019-06-08 17:54:43 +02:00
module: {
2020-02-12 21:31:59 +01:00
rules: [
{
test: /\.s?css$/,
use: [
{
loader: 'style-loader',
options: {},
2020-02-12 21:31:59 +01:00
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
2020-08-14 00:36:26 +02:00
/*{
2020-02-12 21:31:59 +01:00
loader: 'postcss-loader',
options: {
sourceMap: true,
2020-08-14 00:36:26 +02:00
//plugins: [autoprefixer()],
2020-02-12 21:31:59 +01:00
},
2020-08-14 00:36:26 +02:00
},*/
2020-02-12 21:31:59 +01:00
{
loader: 'resolve-url-loader',
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
2019-06-08 17:54:43 +02:00
},
2020-02-12 21:31:59 +01:00
],
},
{
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [
{
loader: 'url-loader',
},
],
},
{
test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/,
2020-02-12 21:31:59 +01:00
use: [
{
loader: 'file-loader',
options: {
name(file) {
return 'public/[path][name].[ext]';
},
},
},
],
},
],
2019-06-08 17:54:43 +02:00
},
2020-09-10 02:53:21 +02:00
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
UINAME: JSON.stringify(UIInfo.name),
UIVERSION: JSON.stringify(UIInfo.version),
UIAUTHOR: JSON.stringify(UIInfo.author),
2020-09-10 20:42:55 +02:00
UIMetaNAME: JSON.stringify(UIMetaInfo.name),
UIMetaVersion: JSON.stringify(UIMetaInfo.version),
2020-09-10 02:53:21 +02:00
}),
],
2019-06-08 17:54:43 +02:00
devServer: {
host: IP,
port: PORT,
historyApiFallback: true,
hot: true,
2019-06-08 17:54:43 +02:00
clientLogLevel: 'info',
disableHostCheck: true,
contentBase: [
path.resolve(__dirname, 'public'),
path.resolve(__dirname, 'public', 'resources'),
path.resolve(__dirname, 'public', 'resources', conf.APPDIR, conf.DIST),
'node_modules',
],
//watchContentBase: true,
overlay: {
warnings: true,
2020-02-12 21:31:59 +01:00
errors: true,
2018-02-05 12:11:01 +01:00
},
2019-06-08 17:54:43 +02:00
headers: {
'Access-Control-Allow-Origin': '*',
2020-02-12 21:31:59 +01:00
},
2019-06-08 17:54:43 +02:00
},
2018-02-05 12:11:01 +01:00
});
2019-04-11 00:15:29 +02:00
module.exports = config;