Skip to content

Commit e29cbe4

Browse files
committed
build(webpack): update webpack to version 2.2.1
update webpack to version 2.2.1, update all dependencies to the newest versions, fix es6-es5 mixed style, fix displaying compilation errors closes halfzebra#71
1 parent 07e3d02 commit e29cbe4

File tree

8 files changed

+122
-91
lines changed

8 files changed

+122
-91
lines changed

bin/elm-app-cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ switch (script) {
3131
break;
3232

3333
case 'test': {
34-
var args = [];
34+
let args = [];
3535
Object.keys(argv || {}).forEach(function (key) {
3636
if (key !== '_' && key !== 'compiler') {
3737
args = args.concat([ '--' + key, argv[ key ] ]);

config/webpack.config.dev.js

+40-23
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,39 @@ module.exports = {
3333
resolveLoader: {
3434

3535
// Look for loaders in own node_modules
36-
root: paths.ownModules,
37-
moduleTemplates: [ '*-loader' ]
36+
modules: [ paths.ownModules ],
37+
moduleExtensions: [ '-loader' ]
3838
},
3939
resolve: {
40-
modulesDirectories: [ 'node_modules' ],
41-
extensions: [ '', '.js', '.elm' ]
40+
modules: [ 'node_modules' ],
41+
extensions: [ '.js', '.elm' ]
4242
},
4343
module: {
4444
noParse: /\.elm$/,
45-
loaders: [
45+
rules: [
4646
{
4747
test: /\.elm$/,
4848
exclude: [ /elm-stuff/, /node_modules/ ],
49-
loader: 'elm-hot!elm-webpack?verbose=true&warn=true&debug=true&pathToMake=' + paths.elmMake
49+
use: [
50+
{loader: 'elm-hot-loader'},
51+
{
52+
loader: 'elm-webpack-loader',
53+
options: {
54+
verbose: true,
55+
warn: true,
56+
debug: true,
57+
pathToMake: paths.elmMake
58+
}
59+
}
60+
]
5061
},
5162
{
5263
test: /\.css$/,
53-
loader: 'style!css!postcss'
64+
use: [
65+
{loader: 'style-loader'},
66+
{loader: 'css-loader'},
67+
{loader: 'postcss-loader'}
68+
]
5469
},
5570
{
5671
exclude: [
@@ -61,40 +76,42 @@ module.exports = {
6176
/\.svg$/
6277
],
6378
loader: 'url',
64-
query: {
79+
options: {
6580
limit: 10000,
6681
name: 'static/media/[name].[hash:8].[ext]'
6782
}
6883
},
6984
// "file" loader for svg
7085
{
7186
test: /\.svg$/,
72-
loader: 'file',
73-
query: {
87+
loader: 'file-loader',
88+
options: {
7489
name: 'static/media/[name].[hash:8].[ext]'
7590
}
7691
}
7792
]
7893
},
79-
postcss: function() {
80-
return [
81-
autoprefixer({
82-
browsers: [
83-
'>1%',
84-
'last 4 versions',
85-
'Firefox ESR',
86-
'not ie < 9'
87-
]
88-
})
89-
];
90-
},
9194
plugins: [
9295
new webpack.DefinePlugin(getClientEnvironment()),
9396
new HtmlWebpackPlugin({
9497
inject: true,
9598
template: paths.template,
9699
favicon: paths.favicon
97100
}),
98-
new webpack.HotModuleReplacementPlugin()
101+
new webpack.HotModuleReplacementPlugin(),
102+
new webpack.LoaderOptionsPlugin({
103+
options: {
104+
postcss: [
105+
autoprefixer({
106+
browsers: [
107+
'>1%',
108+
'last 4 versions',
109+
'Firefox ESR',
110+
'not ie < 9'
111+
]
112+
})
113+
]
114+
}
115+
}),
99116
]
100117
};

config/webpack.config.prod.js

+33-24
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,35 @@ module.exports = {
2828
resolveLoader: {
2929

3030
// Look for loaders in own ./node_modules
31-
root: paths.ownModules,
32-
moduleTemplates: [ '*-loader' ]
31+
modules: [ paths.ownModules ],
32+
moduleExtensions: [ '-loader' ]
3333
},
3434
resolve: {
35-
modulesDirectories: [ 'node_modules' ],
36-
extensions: [ '', '.js', '.elm' ]
35+
modules: [ 'node_modules' ],
36+
extensions: [ '.js', '.elm' ]
3737
},
3838
module: {
3939
noParse: /\.elm$/,
40-
loaders: [
40+
rules: [
4141
{
4242
test: /\.elm$/,
4343
exclude: [ /elm-stuff/, /node_modules/ ],
4444

4545
// Use the local installation of elm-make
46-
loader: 'elm-webpack',
47-
query: {
46+
loader: 'elm-webpack-loader',
47+
options: {
4848
pathToMake: paths.elmMake
4949
}
5050
},
5151
{
5252
test: /\.css$/,
53-
loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer!postcss')
53+
use: ExtractTextPlugin.extract({
54+
fallbackLoader: 'style-loader',
55+
loader: [
56+
{loader: 'css-loader'},
57+
{loader: 'postcss-loader'}
58+
]
59+
})
5460
},
5561
{
5662
exclude: [
@@ -60,34 +66,22 @@ module.exports = {
6066
/\.json$/,
6167
/\.svg$/
6268
],
63-
loader: 'url',
64-
query: {
69+
loader: 'url-loader',
70+
options: {
6571
limit: 10000,
6672
name: 'static/media/[name].[hash:8].[ext]'
6773
}
6874
},
6975
// "file" loader for svg
7076
{
7177
test: /\.svg$/,
72-
loader: 'file',
73-
query: {
78+
loader: 'file-loader',
79+
options: {
7480
name: 'static/media/[name].[hash:8].[ext]'
7581
}
7682
}
7783
]
7884
},
79-
postcss: function() {
80-
return [
81-
autoprefixer({
82-
browsers: [
83-
'>1%',
84-
'last 4 versions',
85-
'Firefox ESR',
86-
'not ie < 9'
87-
]
88-
})
89-
];
90-
},
9185
plugins: [
9286

9387
new AssetsPlugin({ path: paths.dist }),
@@ -111,6 +105,21 @@ module.exports = {
111105
}
112106
}),
113107

108+
new webpack.LoaderOptionsPlugin({
109+
options: {
110+
postcss: [
111+
autoprefixer({
112+
browsers: [
113+
'>1%',
114+
'last 4 versions',
115+
'Firefox ESR',
116+
'not ie < 9'
117+
]
118+
})
119+
]
120+
}
121+
}),
122+
114123
new HtmlWebpackPlugin({
115124
inject: true,
116125
template: paths.template,

package.json

+18-17
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,42 @@
4040
"README.md"
4141
],
4242
"dependencies": {
43-
"assets-webpack-plugin": "^3.5.0",
44-
"autoprefixer": "6.5.4",
45-
"bluebird": "3.4.6",
43+
"assets-webpack-plugin": "^3.5.1",
44+
"autoprefixer": "6.7.2",
45+
"bluebird": "3.4.7",
4646
"chalk": "1.1.3",
47-
"clean-webpack-plugin": "0.1.14",
47+
"clean-webpack-plugin": "0.1.15",
4848
"cli-table": "0.3.1",
4949
"connect-history-api-fallback": "^1.3.0",
5050
"cross-spawn": "5.0.1",
5151
"css-loader": "0.26.1",
52-
"dotenv": "^2.0.0",
52+
"dotenv": "^4.0.0",
5353
"elm": "^0.18.0",
54-
"elm-hot-loader": "0.4.2",
55-
"elm-test": "0.18.0",
56-
"elm-webpack-loader": "3.1.0",
54+
"elm-hot-loader": "0.5.4",
55+
"elm-test": "0.18.2",
56+
"elm-webpack-loader": "4.2.0",
5757
"extend": "3.0.0",
58-
"extract-text-webpack-plugin": "1.0.1",
59-
"file-loader": "0.9.0",
60-
"fs-extra": "1.0.0",
61-
"html-webpack-plugin": "2.24.1",
58+
"extract-text-webpack-plugin": "^2.0.0-rc.2",
59+
"file-loader": "0.10.0",
60+
"fs-extra": "2.0.0",
61+
"html-webpack-plugin": "2.28.0",
6262
"http-proxy-middleware": "^0.17.3",
6363
"minimist": "1.2.0",
64-
"postcss-loader": "1.2.1",
64+
"postcss-loader": "1.2.2",
6565
"prompt": "1.0.0",
6666
"react-dev-utils": "0.4.2",
6767
"style-loader": "0.13.1",
6868
"url-loader": "^0.5.7",
69-
"webpack": "1.14.0",
70-
"webpack-dev-server": "1.16.2"
69+
"webpack": "2.2.1",
70+
"webpack-dev-server": "2.2.1"
7171
},
7272
"devDependencies": {
7373
"chai": "^3.5.0",
7474
"cz-conventional-changelog": "^1.2.0",
7575
"dir-compare": "^1.3.0",
76-
"eslint": "^3.12.2",
77-
"husky": "^0.12.0",
76+
"eslint": "^3.14.1",
77+
"extract-text-webpack-plugin": "^2.0.0-rc.2",
78+
"husky": "^0.13.1",
7879
"mocha": "^3.2.0",
7980
"rimraf": "^2.5.4",
8081
"semantic-release": "^6.3.2"

scripts/build.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ console.log('\nStarting production build...\n');
1717
// Initialize webpack, using the long way: http://webpack.github.io/docs/node.js-api.html#the-long-way
1818
webpack(config).run(function (err, stats) {
1919

20-
if (err !== null) {
21-
console.log(chalk.red(err));
20+
if (stats.compilation.errors.length > 0) {
21+
console.log(stats.toString({
22+
chunks: false,
23+
colors: true,
24+
assets: false,
25+
}));
2226
process.exit(1);
2327
} else {
24-
var statsFormatted = stats.toString({
28+
const statsFormatted = stats.toString({
2529
chunks: false,
2630
colors: true
2731
});
2832

29-
console.log(chalk.green('\n' + statsFormatted));
33+
console.log(statsFormatted);
3034
console.log(chalk.green('\n' + 'Production build is ready in `dist/` folder'));
3135
}
3236
});

scripts/create.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function createElmApp (name) {
2020

2121
console.log('\nCreating ' + name + ' project...\n');
2222

23-
var root = path.resolve(name);
24-
var template = path.join(__dirname, '../template');
23+
const root = path.resolve(name);
24+
const template = path.join(__dirname, '../template');
2525

2626
if (!fs.existsSync(name)) {
2727

@@ -41,7 +41,7 @@ function createElmApp (name) {
4141
process.chdir(root);
4242

4343
// Run initial `elm-package install -y`
44-
var spawnElmPkgResult = spawnSync(executablePaths[ 'elm-package' ], [ 'install', '-y' ], { stdio: 'inherit' });
44+
const spawnElmPkgResult = spawnSync(executablePaths[ 'elm-package' ], [ 'install', '-y' ], { stdio: 'inherit' });
4545

4646
if (spawnElmPkgResult.status === null) {
4747
console.log(chalk.red('\nFailed to install elm packages'));

scripts/eject.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ function diffTable (target, mixin, head) {
2929
head = [ chalk.grey('Name'), chalk.yellow('Old'), chalk.green('New') ];
3030
}
3131

32-
var table = new Table({
32+
const table = new Table({
3333
head: head
3434
});
3535

36-
for (var propName in target) {
36+
for (const propName in target) {
3737
if (propName in mixin) {
38-
var targetPropValue = target[ propName ];
39-
var mixinPropValue = mixin[ propName ];
38+
const targetPropValue = target[ propName ];
39+
const mixinPropValue = mixin[ propName ];
4040
// If found and is not equal
4141
if (targetPropValue !== mixinPropValue) {
4242
table.push([ propName, targetPropValue, mixinPropValue ]);
@@ -49,7 +49,7 @@ function diffTable (target, mixin, head) {
4949

5050
function promptYesOrNo () {
5151
return new Promise(function (resolve, reject) {
52-
var property = {
52+
const property = {
5353
name: 'answer',
5454
message: chalk.yellow('Would you like to continue? [Y/n]')
5555
};
@@ -121,12 +121,12 @@ if (fs.existsSync('elm-package.json') === false) {
121121

122122
if (fs.existsSync('./package.json') === true) {
123123
console.log('Found existing package.json');
124-
var pkgEjected = JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf-8' }));
124+
const pkgEjected = JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf-8' }));
125125

126126
Promise.resolve()
127127
.then(function () {
128128
if (pkgEjected.hasOwnProperty('devDependencies')) {
129-
var diff = diffTable(pkgEjected.devDependencies, devDependencies);
129+
const diff = diffTable(pkgEjected.devDependencies, devDependencies);
130130
if (diff.length !== 0) {
131131
console.log(diff.toString());
132132
console.log('Ejecting wil overwrite your "devDependencies" in package.json\n');
@@ -136,7 +136,7 @@ if (fs.existsSync('./package.json') === true) {
136136
})
137137
.then(function () {
138138
if (pkgEjected.hasOwnProperty('scripts') && Object.keys(pkgEjected.scripts).length === 0) {
139-
var diff = diffTable(pkgEjected.scripts, scripts);
139+
const diff = diffTable(pkgEjected.scripts, scripts);
140140
if (diff.length !== 0) {
141141
console.log(diff.toString());
142142
console.log('Ejecting will overwrite your "scripts" in package.json\n');

0 commit comments

Comments
 (0)