Skip to content

Commit

Permalink
update to use webpack 2
Browse files Browse the repository at this point in the history
  • Loading branch information
haoliangyu committed Mar 25, 2017
1 parent d8be9da commit 07401b2
Show file tree
Hide file tree
Showing 7 changed files with 655 additions and 381 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A web mapping application starter based on Angular 2 and Leaflet. This project d

- [x] Use unofficially typed Leaflet plugin

- [ ] Webpack 2
- [x] Webpack 2

Support [Angular 2.x](https://github.com/angular/angular/blob/master/CHANGELOG.md#200-2016-09-14) and [Leaflet 1.0](https://github.com/Leaflet/Leaflet/blob/master/CHANGELOG.md#101-september-30-2016) now!

Expand Down Expand Up @@ -59,6 +59,8 @@ Thanks to these awesome people!

- [Wolfgang Becker](https://github.com/vimwb)

- [Tonia Roddick](https://github.com/troddick)

Looking for other demos?
-------------------------------

Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@
"@angular/platform-browser-dynamic": "^2.4.7",
"@types/es6-shim": "^0.31.32",
"@types/geojson": "1.0.0",
"@types/leaflet": "^1.0.53",
"@types/leaflet": "^1.0.57",
"bootstrap": "^3.3.7",
"font-awesome": "^4.7.0",
"geojson-vt": "^2.4.0",
"leaflet": "^1.0.3",
"leaflet.vectorgrid": "https://github.com/haoliangyu/Leaflet.VectorGrid.git",
"ng2-bootstrap": "^1.3.3",
"optimize-css-assets-webpack-plugin": "^1.3.0",
"reflect-metadata": "^0.1.9",
"rxjs": "5.1.1",
"zone.js": "^0.7.6"
"ng2-bootstrap": "^1.4.2",
"reflect-metadata": "^0.1.10",
"rxjs": "5.2.0",
"zone.js": "^0.7.2"
},
"devDependencies": {
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.10.0",
"css-loader": "^0.27.3",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.10.1",
"html-webpack-plugin": "^2.28.0",
"less": "^2.7.2",
"less-loader": "^2.2.3",
"less-loader": "^4.0.2",
"optimize-css-assets-webpack-plugin": "^1.3.0",
"optimize-js-plugin": "0.0.4",
"raw-loader": "^0.5.1",
"script-ext-html-webpack-plugin": "^1.7.1",
"style-loader": "^0.13.1",
"style-loader": "^0.16.0",
"to-string-loader": "^1.1.5",
"ts-loader": "^2.0.0",
"tslint": "^4.4.2",
"tslint-loader": "^3.4.2",
"typescript": "^2.1.6",
"url-loader": "^0.5.7",
"webpack": "^1.1.14",
"webpack-cleanup-plugin": "^0.4.2"
"ts-loader": "^2.0.3",
"tslint": "^4.5.1",
"tslint-loader": "^3.4.3",
"typescript": "^2.2.1",
"url-loader": "^0.5.8",
"webpack": "^2.3.2",
"webpack-cleanup-plugin": "^0.5.1"
}
}
13 changes: 13 additions & 0 deletions public_src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/// <reference path="./typings/require.d.ts"/>
/// <reference path="./typings/leaflet.vectorgrid.d.ts"/>

import "leaflet";
import "leaflet.vectorgrid";
import "zone.js/dist/zone";
import "zone.js/dist/long-stack-trace-zone";
import "reflect-metadata";

import "bootstrap/dist/css/bootstrap.css";
import "font-awesome/css/font-awesome.css";
import "leaflet/dist/leaflet.css";

import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {HttpModule} from "@angular/http";
import {NgModule} from "@angular/core";
Expand Down
12 changes: 0 additions & 12 deletions public_src/libs.ts

This file was deleted.

36 changes: 15 additions & 21 deletions webpack/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,35 @@ const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');

const srcDir = 'public_src';
const outputDir = 'public';
const outputDir = '../public';

module.exports = {
devtool: "eval",
debug: true,
entry: {
libs: path.resolve(srcDir, 'libs.ts'),
app: path.resolve(srcDir, 'bootstrap.ts')
},
output: {
path: outputDir,
path: path.resolve(__dirname, outputDir),
filename: '[name].[hash].bundle.js',
sourceMapFilename: '[name].[hash].map',
chunkFilename: '[id].[hash].chunk.js'
},
resolve: {
extensions: ['', '.ts', '.component.ts', '.service.ts', '.js', '.component.html', '.component.less', '.less', '.css']
extensions: ['.ts', '.component.ts', '.service.ts', '.js', '.component.html', '.component.less', '.less', '.css']
},
module: {
preLoaders: [
{ test: /\.ts$/, loader: 'tslint' }
],
loaders: [
{ test: /(\.component|\.service|)\.ts$/, loader: 'ts-loader'},
{ test: /\.component\.html$/, loader: 'raw' },
{ test: /(\.component|)\.less$/, loader: 'to-string!css!less' },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
{ test: /\.(png|gif|jpg)$/, loader: "file?name=images/[name].[ext]" },
// For font-awesome, created by Turbo87:
// https://gist.github.com/Turbo87/e8e941e68308d3b40ef6
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" }
rules: [
{ test: /\.ts$/, enforce: 'pre', loader: 'tslint-loader' },
{ test: /(\.component|\.service|)\.ts$/, use: ['ts-loader'] },
{ test: /\.component\.html$/, use: ['raw-loader'] },
{ test: /(\.component|)\.less$/, use: ['to-string-loader', 'css-loader', 'less-loader'] },
{ test: /\.css$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })},
{ test: /\.(png|gif|jpg)$/, use:[{ loader: 'file-loader', options: { name: 'images/[name].[ext]'} } ]},
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]}
],
noParse: [ path.join(__dirname, 'node_modules', 'angular2', 'bundles') ]
},
Expand Down
36 changes: 15 additions & 21 deletions webpack/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,35 @@ const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');

const srcDir = 'public_src';
const outputDir = 'public';
const outputDir = '../public';

module.exports = {
devtool: "source-map",
debug: false,
entry: {
libs: path.resolve(srcDir, 'libs.ts'),
app: path.resolve(srcDir, 'bootstrap.ts')
},
output: {
path: outputDir,
path: path.resolve(__dirname, outputDir),
filename: '[name].[hash].bundle.js',
sourceMapFilename: '[name].[hash].map',
chunkFilename: '[id].[hash].chunk.js'
},
resolve: {
extensions: ['', '.ts', '.component.ts', '.service.ts', '.js', '.component.html', '.component.less', '.less', '.css']
extensions: ['.ts', '.component.ts', '.service.ts', '.js', '.component.html', '.component.less', '.less', '.css']
},
module: {
preLoaders: [
{ test: /\.ts$/, loader: 'tslint' }
],
loaders: [
{ test: /(\.component|\.service|)\.ts$/, loader: 'ts-loader'},
{ test: /\.component\.html$/, loader: 'raw' },
{ test: /(\.component|)\.less$/, loader: 'to-string!css!less' },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
{ test: /\.(png|gif|jpg)$/, loader: "file?name=images/[name].[ext]" },
// For font-awesome, created by Turbo87:
// https://gist.github.com/Turbo87/e8e941e68308d3b40ef6
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "file?name=fonts/[name].[ext]" }
rules: [
{ test: /\.ts$/, enforce: 'pre', loader: 'tslint-loader' },
{ test: /(\.component|\.service|)\.ts$/, use: ['ts-loader'] },
{ test: /\.component\.html$/, use: ['raw-loader'] },
{ test: /(\.component|)\.less$/, use: ['to-string-loader', 'css-loader', 'less-loader'] },
{ test: /\.css$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })},
{ test: /\.(png|gif|jpg)$/, use:[{ loader: 'file-loader', options: { name: 'images/[name].[ext]'} } ]},
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]},
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use:[{ loader: 'file-loader', options: { name: 'fonts/[name].[ext]'} } ]}
],
noParse: [ path.join(__dirname, 'node_modules', 'angular2', 'bundles') ]
},
Expand Down
Loading

0 comments on commit 07401b2

Please sign in to comment.