Skip to content

Commit 8435340

Browse files
committed
webpack config
1 parent 5a58d95 commit 8435340

File tree

5 files changed

+56
-24
lines changed

5 files changed

+56
-24
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

bower.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "easy-learn",
33
"version": "0.0.0",
44
"dependencies": {
5-
"angular": "^1.5.0",
65
"angular-local-storage": "~0.2.2",
76
"angular-animate": "~1.5.0",
87
"angular-ui-router": "^0.2.18",

package.json

+12-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
"electronVersion": "0.36.9",
77
"scripts": {
88
"start": "export NODE_ENV='dev'; electron ./dist/main.js",
9-
"build": "electron-packager ./dist/ easy-learn --platform=darwin --arch=x64 --out ~/Desktop/easy-learn --asar --version 0.36.9 --overwrite --icon=./src/images/app-icon.icns",
10-
"buildwin": "electron-packager ./dist/ easy-learn --platform=win32 --arch=x64 --out ~/Desktop/easy-learn --version 0.36.9 --overwrite --icon=./src/images/app-icon.ico"
9+
"buildMac": "electron-packager ./dist/ easy-learn --platform=darwin --arch=x64 --out ~/Desktop/easy-learn --asar --version 0.36.9 --overwrite --icon=./src/images/app-icon.icns",
10+
"buildwin": "electron-packager ./dist/ easy-learn --platform=win32 --arch=x64 --out ~/Desktop/easy-learn --version 0.36.9 --overwrite --icon=./src/images/app-icon.ico",
11+
"build": "webpack --progress --colors"
1112
},
1213
"devDependencies": {
1314
"babel-core": "^6.7.2",
1415
"babel-loader": "^6.2.4",
1516
"babel-preset-es2015": "^6.6.0",
1617
"browser-sync": "^2.11.1",
1718
"browser-sync-spa": "^1.0.3",
19+
"clean-webpack-plugin": "^0.1.8",
20+
"copy-webpack-plugin": "^1.1.1",
1821
"css-loader": "^0.23.1",
1922
"del": "^2.2.0",
2023
"electron-packager": "^5.1.0",
@@ -40,13 +43,19 @@
4043
"gulp-svg-sprite": "^1.2.19",
4144
"html-loader": "^0.4.3",
4245
"html-webpack-plugin": "^2.10.0",
46+
"less-loader": "^2.2.2",
4347
"main-bower-files": "^2.11.1",
4448
"ng-annotate-loader": "^0.1.0",
4549
"ng-annotate-webpack-plugin": "^0.1.2",
4650
"require-dir": "^0.3.0",
4751
"run-sequence": "^1.1.5",
4852
"style-loader": "^0.13.0",
53+
"svg-sprite-loader": "0.0.18",
4954
"util": "^0.10.3",
50-
"webpack": "^1.12.14"
55+
"webpack": "^1.12.14",
56+
"webpack-svgstore-plugin": "^2.1.3"
57+
},
58+
"dependencies": {
59+
"angular": "^1.5.0"
5160
}
5261
}

src/app/app.js src/app/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import './app.less';
2+
import '../svg/close.svg';
3+
4+
import angular from 'angular';
5+
16
angular.module('easy-learn', [
27
'ngAnimate',
38
'LocalStorageModule',

webpack.config.js

+36-20
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ const path = require('path');
55
const webpack = require('webpack');
66
const CleanWebpackPlugin = require('clean-webpack-plugin');
77
const HtmlWebpackPlugin = require('html-webpack-plugin');
8+
const CopyWebpackPlugin = require('copy-webpack-plugin');
89

910
const DIR = {
1011
src: path.join(__dirname, 'src'),
11-
dist: path.join(__dirname, 'dist')
12+
dist: path.join(__dirname, 'dist1')
1213
};
1314

1415
module.exports = {
1516

16-
entry: DIR.src + '/app',
17+
entry: {
18+
'main': DIR.src + '/app'
19+
},
1720

1821
output: {
1922
path: DIR.dist,
@@ -22,11 +25,11 @@ module.exports = {
2225
},
2326

2427
resolve: {
25-
modulesDirectories: ['node_modules', 'bower_components'],
28+
modulesDirectories: ['node_modules'],
2629
alias: {
27-
compat: path.join(DIR.src, 'compat'),
28-
components: path.join(DIR.src, 'components'),
29-
services: path.join(DIR.src, 'services')
30+
// compat: path.join(DIR.src, 'compat'),
31+
// components: path.join(DIR.src, 'components'),
32+
// services: path.join(DIR.src, 'services')
3033
}
3134
},
3235

@@ -37,28 +40,30 @@ module.exports = {
3740
}),
3841

3942
new HtmlWebpackPlugin({
40-
template: 'src/index.html'
43+
template: 'src/index.html',
44+
inject: 'body'
4145
}),
4246

4347
new webpack.HotModuleReplacementPlugin(),
44-
45-
new webpack.ResolverPlugin([
46-
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin('bower.json', ['main'])
47-
]),
48-
4948
new webpack.optimize.CommonsChunkPlugin({
5049
name: 'main',
5150
async: true
52-
})
51+
}),
52+
53+
new CopyWebpackPlugin([
54+
{ from: DIR.src + '/images', to: 'images'},
55+
{ from: DIR.src + '/main.js'},
56+
{ from: DIR.src + '/package.json'}
57+
])
5358
],
5459

5560
module: {
5661
preLoaders: [
57-
{
58-
// test: /\.js$/,
59-
// loader: 'eslint',
60-
// exclude: /node_modules|bower_components/
61-
}
62+
// {
63+
// test: /\.js$/,
64+
// loader: 'eslint',
65+
// exclude: /node_modules|bower_components/
66+
// }
6267
],
6368
loaders: [
6469
{
@@ -67,19 +72,30 @@ module.exports = {
6772
},
6873
{
6974
test: /\.js$/,
70-
loader: 'babel',
75+
loader: 'ng-annotate!babel',
7176
exclude: /node_modules|bower_components/
7277
},
7378
{
7479
test: /\.html$/,
7580
loader: 'html'
7681
},
82+
{
83+
test: /\.less$/,
84+
loader: "style!css!less"
85+
},
7786
{
7887
test: /\.css$/,
7988
loader: 'style!css'
8089
},
8190
{
82-
test: /(\.eot|\.ttf|\.woff2?|\.svg)$/,
91+
test: /\.svg$/,
92+
loader: 'svg-sprite?' + JSON.stringify({
93+
name: '[name]',
94+
angularBaseWorkaround: true
95+
})
96+
},
97+
{
98+
test: /(\.eot|\.ttf|\.woff2?)$/,
8399
loader: 'url'
84100
}
85101
]

0 commit comments

Comments
 (0)