Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Commit fb862b3

Browse files
committed
Init webpack
1 parent 46e5f5a commit fb862b3

File tree

5 files changed

+168
-0
lines changed

5 files changed

+168
-0
lines changed

.babelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"stage-0"
5+
],
6+
"plugins": [
7+
"syntax-decorators",
8+
"syntax-flow",
9+
"transform-runtime",
10+
"transform-decorators-legacy",
11+
"transform-flow-comments"
12+
]
13+
}

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"private": true,
3+
"main": "index.js",
4+
"scripts": {
5+
"build": "cross-env BABEL_ENV=production ./node_modules/.bin/webpack -p --config webpack.prod.js",
6+
"watch": "cross-env BABEL_ENV=dev ./node_modules/.bin/webpack --config webpack.dev.js --progress --colors --watch",
7+
"test": "npm run lint"
8+
},
9+
"keywords": [
10+
"es6",
11+
"babel",
12+
"webpack"
13+
],
14+
"license": "MIT",
15+
"devDependencies": {
16+
"babel-core": "^6.25.0",
17+
"babel-loader": "^7.1.1",
18+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
19+
"babel-plugin-transform-flow-comments": "^6.22.0",
20+
"babel-plugin-transform-runtime": "^6.23.0",
21+
"babel-preset-es2015": "^6.24.1",
22+
"babel-preset-stage-0": "^6.24.1",
23+
"babel-runtime": "^6.23.0",
24+
"cross-env": "^5.0.1",
25+
"css-loader": "^0.28.4",
26+
"extract-text-webpack-plugin": "^3.0.0",
27+
"html-loader": "^0.4.5",
28+
"node-sass": "^4.5.3",
29+
"postcss-loader": "^2.0.6",
30+
"raw-loader": "^0.5.1",
31+
"sass-lint": "^1.10.2",
32+
"sass-loader": "^6.0.6",
33+
"style-loader": "^0.18.2",
34+
"vue-loader": "^13.0.1",
35+
"vue-template-compiler": "^2.3.4",
36+
"webpack": "^3.2.0"
37+
},
38+
"dependencies": {
39+
"vue": "^2.3",
40+
"babel-polyfill": "^6.26",
41+
"font-awesome": "^4.7"
42+
}
43+
}

postcss.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
plugins: [
3+
require('autoprefixer')
4+
]
5+
};

webpack.base.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
const webpack = require('webpack');
2+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
3+
4+
module.exports = (config) => {
5+
const JsLoader = [
6+
{
7+
loader: 'babel-loader',
8+
options: {
9+
sourceMap: true
10+
}
11+
},
12+
];
13+
14+
const CssLoader = ExtractTextPlugin.extract({
15+
use: [
16+
{
17+
loader: 'css-loader',
18+
options: {
19+
url: true,
20+
minimize: true,
21+
import: true,
22+
sourceMap: true
23+
}
24+
},
25+
{
26+
loader: 'postcss-loader',
27+
options: {
28+
sourceMap: true
29+
}
30+
},
31+
{
32+
loader: 'sass-loader',
33+
options: {
34+
includePaths: config.resolve,
35+
precision: 10,
36+
sourceMap: true
37+
}
38+
}
39+
],
40+
fallback: 'vue-style-loader'
41+
});
42+
43+
44+
return {
45+
entry: config.entry,
46+
devtool: config.devtool,
47+
output: {
48+
path: config.out.path,
49+
filename: (config.out.file || 'index') + '.js'
50+
},
51+
resolve: {
52+
modules: config.resolve.concat(['node_modules']),
53+
alias: config.alias
54+
},
55+
module: {
56+
rules: [
57+
{
58+
test: /\.vue$/,
59+
loader: 'vue-loader',
60+
options: {
61+
esModule: false,
62+
preserveWhitespace: false,
63+
extractCSS: true,
64+
loaders: {
65+
scss: CssLoader,
66+
sass: CssLoader,
67+
css: CssLoader,
68+
js: JsLoader,
69+
}
70+
}
71+
},
72+
{
73+
test: /\.js$/,
74+
include: config.resolve.concat(['node_modules']),
75+
use: JsLoader
76+
},
77+
{
78+
test: /\.(:?sc|sa|c)ss$/,
79+
use: CssLoader
80+
},
81+
].concat(config.rules || [])
82+
},
83+
plugins: config.plugins.concat([
84+
new ExtractTextPlugin((config.out.file || 'index') + '.css'),
85+
new webpack.optimize.ModuleConcatenationPlugin(),
86+
])
87+
}
88+
};

webpack.dev.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = require('./webpack.base.js')({
2+
devtool: 'source-map',
3+
entry: `${__dirname}/src/index`,
4+
out: {
5+
path: `${__dirname}/dist/`,
6+
file: 'index'
7+
},
8+
resolve: [
9+
`${__dirname}/src`,
10+
`${__dirname}/src/styles`,
11+
],
12+
alias: {
13+
vue: 'vue/dist/vue.js'
14+
},
15+
plugins: [
16+
17+
],
18+
rules: []
19+
});

0 commit comments

Comments
 (0)