Skip to content

Commit

Permalink
Merge branch 'release/2.3.3' into craft-webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Aug 14, 2020
2 parents 199f62f + d3698a1 commit 144632d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 113 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# nystudio107/craft Change Log

## 2.3.3 - 2020.08.13
### Fixed
* Modern config only for local dev, [fixing multi-compiler issues](https://github.com/webpack/webpack-dev-server/issues/2355) with HRM

## 2.3.2 - 2020.08.12
### Changed
* Remove `[hash]` from dev config to eliminate potential [memory errors](https://github.com/webpack/webpack-dev-server/issues/438)
Expand Down
175 changes: 63 additions & 112 deletions buildchain/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
// webpack.dev.js - developmental builds
const LEGACY_CONFIG = 'legacy';
const MODERN_CONFIG = 'modern';

// node modules
const merge = require('webpack-merge');
const path = require('path');
const webpack = require('webpack');

// webpack plugins
var DashboardPlugin = require('webpack-dashboard/plugin');
const DashboardPlugin = require('webpack-dashboard/plugin');

// config files
const common = require('./webpack.common.js');
const pkg = require('./package.json');
const settings = require('./webpack.settings.js');

// Configure the webpack-dev-server
const configureDevServer = (buildType) => {
const configureDevServer = () => {
return {
public: settings.devServerConfig.public(),
contentBase: path.resolve(__dirname, settings.paths.templates),
Expand All @@ -38,121 +36,74 @@ const configureDevServer = (buildType) => {
};

// Configure Image loader
const configureImageLoader = (buildType) => {
if (buildType === LEGACY_CONFIG) {
return {
test: /\.(png|jpe?g|gif|svg|webp)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'img/[name].[ext]'
}
}
]
};
}
if (buildType === MODERN_CONFIG) {
return {
test: /\.(png|jpe?g|gif|svg|webp)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'img/[name].[ext]'
}
const configureImageLoader = () => {
return {
test: /\.(png|jpe?g|gif|svg|webp)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'img/[name].[ext]'
}
]
};
}
}
]
};
};

// Configure the Postcss loader
const configurePostcssLoader = (buildType) => {
// Don't generate CSS for the legacy config in development
if (buildType === LEGACY_CONFIG) {
return {
test: /\.(pcss|css)$/,
loader: 'ignore-loader'
};
}
if (buildType === MODERN_CONFIG) {
return {
test: /\.(pcss|css)$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'vue-style-loader',
},
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: true
}
},
{
loader: 'resolve-url-loader'
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
config: {
path: path.resolve(__dirname),
}
const configurePostcssLoader = () => {
return {
test: /\.(pcss|css)$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'vue-style-loader',
},
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: true
}
},
{
loader: 'resolve-url-loader'
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
config: {
path: path.resolve(__dirname),
}
}
]
};
}
}
]
};
};

// Development module exports
module.exports = [
merge(
common.legacyConfig,
{
output: {
filename: path.join('./js', '[name]-legacy.js'),
publicPath: settings.devServerConfig.public() + '/',
},
mode: 'development',
devtool: 'inline-source-map',
devServer: configureDevServer(LEGACY_CONFIG),
module: {
rules: [
configurePostcssLoader(LEGACY_CONFIG),
configureImageLoader(LEGACY_CONFIG),
],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
}
),
merge(
common.modernConfig,
{
output: {
filename: path.join('./js', '[name].js'),
publicPath: settings.devServerConfig.public() + '/',
},
mode: 'development',
devtool: 'inline-source-map',
devServer: configureDevServer(MODERN_CONFIG),
module: {
rules: [
configurePostcssLoader(MODERN_CONFIG),
configureImageLoader(MODERN_CONFIG),
],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new DashboardPlugin(),
module.exports = merge(
common.modernConfig,
{
output: {
filename: path.join('./js', '[name].js'),
publicPath: settings.devServerConfig.public() + '/',
},
mode: 'development',
devtool: 'inline-source-map',
devServer: configureDevServer(),
module: {
rules: [
configurePostcssLoader(),
configureImageLoader(),
],
}
),
];
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new DashboardPlugin(),
],
}
);
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "craftcms/craft",
"description": "nystudio107 Craft 3.4 CMS scaffolding project",
"version": "2.3.2",
"version": "2.3.3",
"keywords": [
"craft",
"cms",
Expand Down

0 comments on commit 144632d

Please sign in to comment.