Skip to content

Commit 16cf261

Browse files
committed
chore(webpack): update webpack 2 for dev
1 parent b39ac0b commit 16cf261

File tree

6 files changed

+718
-946
lines changed

6 files changed

+718
-946
lines changed

build/webpack.base.conf.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,53 @@
1-
var path = require('path')
2-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
1+
const path = require('path')
32

43
module.exports = {
54
entry: {
6-
app: './src/main.js'
5+
main: path.resolve(__dirname, '../src/main.js'),
76
},
87
output: {
98
path: path.resolve(__dirname, '../dist'),
109
publicPath: '/',
1110
filename: 'build.js',
1211
},
1312
resolve: {
14-
extensions: ['', '.js', '.vue'],
13+
extensions: ['.json', '.js', '.vue'],
1514
alias: {
16-
vue$: 'vue/dist/vue.common.js',
1715
components: path.resolve(__dirname, '../src/components'),
1816
},
1917
},
20-
resolveLoader: {
21-
root: path.join(__dirname, 'node_modules'),
22-
},
2318
module: {
24-
loaders: [
19+
rules: [
2520
{
2621
test: /\.vue$/,
27-
loader: 'vue',
22+
use: 'vue-loader',
2823
},
2924
{
3025
test: /\.js$/,
31-
loader: 'babel!eslint',
26+
use: 'babel-loader',
3227
exclude: /node_modules/
3328
},
34-
{
35-
test: /\.json$/,
36-
loader: 'json',
37-
},
3829
{
3930
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
40-
loader: 'url',
31+
use: {
32+
loader: 'url-loader',
33+
options: {
34+
limit: 10000,
35+
name: 'images/[name].[hash:7].[ext]',
36+
},
37+
},
4138
},
39+
4240
{
4341
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
44-
loader: 'url',
42+
use: {
43+
loader: 'url-loader',
44+
options: {
45+
limit: 10000,
46+
name: 'fonts/[name].[hash:7].[ext]',
47+
},
48+
},
4549
},
46-
],
47-
},
4850

49-
eslint: {
50-
formatter: require('eslint-friendly-formatter')
51+
],
5152
},
5253
}

build/webpack.dev.conf.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
var config = require('./webpack.base.conf')
2-
var HtmlWebpackPlugin = require('html-webpack-plugin')
1+
const config = require('./webpack.base.conf')
2+
const HtmlWebpackPlugin = require('html-webpack-plugin')
3+
const webpack = require('webpack')
4+
const path = require('path')
35

4-
// eval-source-map is faster for development
5-
config.devtool = 'eval-source-map'
6+
config.devtool = '#eval-source-map'
67

78
config.devServer = {
8-
// allow access over local network
99
host: 'localhost',
1010
port: 1805,
11-
// enable HTML5 history routing
1211
historyApiFallback: true,
13-
// suppress useless text
12+
hotOnly: true,
13+
overlay: true,
1414
noInfo: true,
1515
}
1616

17-
// necessary for the html plugin to work properly
18-
// when serving the html from in-memory
19-
config.output.publicPath = '/'
20-
config.module.loaders = (config.module.loaders || []).concat([
17+
config.module.rules = (config.module.rules || []).concat([
2118
{
2219
test: /\.css$/,
2320
loader: "style!css"
2421
},
2522
])
2623

2724
config.plugins = (config.plugins || []).concat([
28-
// generate HTML on the fly
25+
new webpack.DefinePlugin({
26+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
27+
}),
28+
2929
new HtmlWebpackPlugin({
30+
title: 'BookUp',
3031
filename: 'index.html',
31-
template: 'src/index.html'
32-
})
32+
template: path.resolve(__dirname, '../src/index.html'),
33+
}),
34+
35+
new webpack.optimize.OccurrenceOrderPlugin(),
36+
new webpack.NoEmitOnErrorsPlugin(),
3337
])
3438

3539
module.exports = config
36-
37-
38-
39-
// new ExtractTextPlugin("vue-image-lightbox.min.css"),

dist/build.js

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/build.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,17 @@
3737
"babel-preset-stage-2": "^6.0.0",
3838
"babel-runtime": "^6.0.0",
3939
"css-loader": "^0.23.0",
40-
"eslint": "^1.10.3",
41-
"eslint-friendly-formatter": "^1.2.2",
42-
"eslint-loader": "^1.2.0",
4340
"extract-text-webpack-plugin": "^1.0.1",
4441
"file-loader": "^0.8.4",
45-
"function-bind": "^1.0.2",
4642
"html-webpack-plugin": "^1.7.0",
47-
"inject-loader": "^2.0.1",
48-
"json-loader": "^0.5.4",
4943
"rimraf": "^2.5.0",
5044
"style-loader": "^0.13.1",
5145
"url-loader": "^0.5.7",
5246
"vue": "2.1.10",
53-
"vue-hot-reload-api": "^1.2.0",
54-
"vue-html-loader": "^1.0.0",
5547
"vue-loader": "^11.0.0",
56-
"webpack": "^1.12.2",
57-
"webpack-dev-server": "^1.12.0",
58-
"vue-template-compiler": "^2.1.10"
48+
"vue-template-compiler": "^2.1.10",
49+
"webpack": "^2.6.0",
50+
"webpack-dev-server": "^2.4.5"
5951
},
6052
"dependencies": {
6153
"vue-lazyload": ">1.0.0-rc10"

0 commit comments

Comments
 (0)