Update dependencies & webpack compatibility (BREAKING CHANGES)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
const path = require('path');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const glob = require('glob-all');
|
||||
const merge = require('lodash/merge');
|
||||
|
||||
const mergeWithConcat = require('./util/mergeWithConcat');
|
||||
const userConfig = require('../config');
|
||||
@@ -30,19 +29,20 @@ const config = mergeWithConcat({
|
||||
watch: [],
|
||||
}, userConfig);
|
||||
|
||||
const files = glob.sync(config.copy, {
|
||||
cwd: config.paths.assets,
|
||||
mark: true,
|
||||
}).filter(file => !((file.slice(-1) === '/') || (!file.indexOf('*') === -1)))
|
||||
.map(file => path.join(config.paths.assets, file));
|
||||
|
||||
Object.keys(config.entry).forEach(id =>
|
||||
config.entry[id].unshift(path.join(__dirname, 'public-path.js')));
|
||||
|
||||
module.exports = mergeWithConcat(config, {
|
||||
env: merge({ production: isProduction, development: !isProduction }, argv.env),
|
||||
entry: {
|
||||
get files() {
|
||||
return glob.sync(config.copy, {
|
||||
cwd: config.paths.assets,
|
||||
mark: true,
|
||||
}).filter(file => !((file.slice(-1) === '/') || (!file.indexOf('*') === -1)))
|
||||
.map(file => path.join(config.paths.assets, file));
|
||||
},
|
||||
},
|
||||
env: Object.assign({ production: isProduction, development: !isProduction }, argv.env),
|
||||
publicPath: `${config.publicPath}/${path.basename(config.paths.dist)}/`,
|
||||
});
|
||||
|
||||
if (files.length) {
|
||||
module.exports = mergeWithConcat(module.exports, { entry: { files } });
|
||||
}
|
||||
|
||||
@@ -42,15 +42,14 @@ const webpackConfig = {
|
||||
filename: `scripts/${assetsFilenames}.js`,
|
||||
},
|
||||
module: {
|
||||
preLoaders: [
|
||||
rules: [
|
||||
jsLoader,
|
||||
{
|
||||
enforce: 'pre',
|
||||
test: /\.js?$/,
|
||||
include: config.paths.assets,
|
||||
loader: 'eslint',
|
||||
},
|
||||
],
|
||||
loaders: [
|
||||
jsLoader,
|
||||
{
|
||||
test: /\.css$/,
|
||||
include: config.paths.assets,
|
||||
@@ -110,12 +109,14 @@ const webpackConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
modules: [
|
||||
config.paths.assets,
|
||||
'node_modules',
|
||||
'bower_components',
|
||||
],
|
||||
enforceExtensions: false,
|
||||
resolve: {
|
||||
modules: [
|
||||
config.paths.assets,
|
||||
'node_modules',
|
||||
'bower_components',
|
||||
],
|
||||
enforceExtension: false,
|
||||
},
|
||||
externals: {
|
||||
jquery: 'jQuery',
|
||||
},
|
||||
@@ -163,18 +164,21 @@ const webpackConfig = {
|
||||
minimize: config.enabled.minify,
|
||||
debug: config.enabled.watcher,
|
||||
stats: { colors: true },
|
||||
postcss: [
|
||||
autoprefixer({
|
||||
browsers: [
|
||||
'last 2 versions',
|
||||
'android 4',
|
||||
'opera 12',
|
||||
],
|
||||
}),
|
||||
],
|
||||
eslint: {
|
||||
failOnWarning: false,
|
||||
failOnError: true,
|
||||
}),
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
test: /\.s?css$/,
|
||||
options: {
|
||||
output: { path: config.paths.dist },
|
||||
context: config.paths.assets,
|
||||
postcss: [
|
||||
autoprefixer({ browsers: ['last 2 versions', 'android 4', 'opera 12'] }),
|
||||
],
|
||||
},
|
||||
}),
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
test: /\.js$/,
|
||||
options: {
|
||||
eslint: { failOnWarning: false, failOnError: true },
|
||||
},
|
||||
}),
|
||||
],
|
||||
@@ -187,9 +191,8 @@ if (config.env.production) {
|
||||
}
|
||||
|
||||
if (config.enabled.watcher) {
|
||||
module.exports = mergeWithConcat(webpackConfig, webpackConfigWatch, {
|
||||
entry: addHotMiddleware(webpackConfig.entry),
|
||||
});
|
||||
module.exports.entry = addHotMiddleware(webpackConfig.entry);
|
||||
module.exports = mergeWithConcat(webpackConfig, webpackConfigWatch);
|
||||
}
|
||||
|
||||
if (config.enabled.uglifyJs) {
|
||||
|
||||
@@ -6,7 +6,6 @@ const config = require('./config');
|
||||
|
||||
module.exports = {
|
||||
output: { pathinfo: true },
|
||||
debug: true,
|
||||
devtool: '#cheap-module-source-map',
|
||||
plugins: [
|
||||
new webpack.optimize.OccurrenceOrderPlugin(),
|
||||
|
||||
Reference in New Issue
Block a user