Update webpack 3.1.0 et al
This commit is contained in:
@@ -57,4 +57,4 @@ if (process.env.SAGE_DIST_PATH) {
|
||||
* wp_localize_script('sage/main.js', 'SAGE_DIST_PATH', get_theme_file_uri('dist/'))
|
||||
*/
|
||||
// Object.keys(module.exports.entry).forEach(id =>
|
||||
// module.exports.entry[id].unshift(path.join(__dirname, 'public-path.js')));
|
||||
// module.exports.entry[id].unshift(path.join(__dirname, 'helpers/public-path.js')));
|
||||
|
||||
7
resources/assets/build/helpers/hmr-client.js
Normal file
7
resources/assets/build/helpers/hmr-client.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const hotMiddlewareScript = require('webpack-hot-middleware/client?noInfo=true&timeout=20000&reload=true');
|
||||
|
||||
hotMiddlewareScript.subscribe(event => {
|
||||
if (event.action === 'reload') {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
@@ -6,11 +6,10 @@
|
||||
*/
|
||||
module.exports = (entry) => {
|
||||
const results = {};
|
||||
const hotMiddlewareScript = 'webpack-hot-middleware/client?timeout=20000&reload=true';
|
||||
|
||||
Object.keys(entry).forEach((name) => {
|
||||
results[name] = Array.isArray(entry[name]) ? entry[name].slice(0) : [entry[name]];
|
||||
results[name].unshift(hotMiddlewareScript);
|
||||
results[name].unshift(`${__dirname}/../helpers/hmr-client.js`);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
@@ -51,8 +51,10 @@ let webpackConfig = {
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: [/(node_modules|bower_components)(?)/],
|
||||
loader: 'buble',
|
||||
options: { objectAssign: 'Object.assign' },
|
||||
use: [
|
||||
{ loader: 'cache' },
|
||||
{ loader: 'buble', options: { objectAssign: 'Object.assign' } },
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
@@ -60,6 +62,7 @@ let webpackConfig = {
|
||||
use: ExtractTextPlugin.extract({
|
||||
fallback: 'style',
|
||||
use: [
|
||||
{ loader: 'cache' },
|
||||
{ loader: 'css', options: { sourceMap: config.enabled.sourceMaps } },
|
||||
{
|
||||
loader: 'postcss', options: {
|
||||
@@ -76,6 +79,7 @@ let webpackConfig = {
|
||||
use: ExtractTextPlugin.extract({
|
||||
fallback: 'style',
|
||||
use: [
|
||||
{ loader: 'cache' },
|
||||
{ loader: 'css', options: { sourceMap: config.enabled.sourceMaps } },
|
||||
{
|
||||
loader: 'postcss', options: {
|
||||
@@ -103,8 +107,8 @@ let webpackConfig = {
|
||||
loader: 'url',
|
||||
options: {
|
||||
limit: 4096,
|
||||
publicPath: '../',
|
||||
name: `vendor/${config.cacheBusting}.[ext]`,
|
||||
outputPath: 'vendor/',
|
||||
name: `${config.cacheBusting}.[ext]`,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user