Update webpack 3.1.0 et al

This commit is contained in:
2017-07-09 07:28:28 -07:00
parent 949fa86c38
commit afbaf8fb2e
9 changed files with 268 additions and 197 deletions

View File

@@ -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')));

View 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();
}
});

View File

@@ -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;
};

View File

@@ -51,8 +51,10 @@ let webpackConfig = {
{
test: /\.js$/,
exclude: [/(node_modules|bower_components)(?![/|\\](bootstrap|foundation-sites))/],
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]`,
},
},
],