mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Update KnockoutSpa to Webpack 2 (plus awesome-typescript-loader)
This commit is contained in:
@@ -12,13 +12,14 @@
|
||||
"@types/requirejs": "^2.1.26",
|
||||
"@types/signals": "0.0.16",
|
||||
"@types/whatwg-fetch": "0.0.30",
|
||||
"aspnet-webpack": "^1.0.17",
|
||||
"aspnet-webpack": "^1.0.27",
|
||||
"awesome-typescript-loader": "3.0.0-beta.13 || ^3.0.0",
|
||||
"bootstrap": "^3.3.6",
|
||||
"bundle-loader": "^0.5.4",
|
||||
"crossroads": "^0.12.2",
|
||||
"css-loader": "^0.25.0",
|
||||
"event-source-polyfill": "^0.0.7",
|
||||
"extract-text-webpack-plugin": "^1.0.1",
|
||||
"extract-text-webpack-plugin": "^2.0.0-rc",
|
||||
"file-loader": "^0.9.0",
|
||||
"history": "^4.3.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
@@ -27,10 +28,9 @@
|
||||
"knockout": "^3.4.0",
|
||||
"raw-loader": "^0.5.1",
|
||||
"style-loader": "^0.13.1",
|
||||
"ts-loader": "^0.8.2",
|
||||
"typescript": "^2.0.3",
|
||||
"url-loader": "^0.5.7",
|
||||
"webpack": "^1.13.2",
|
||||
"webpack": "^2.2.0",
|
||||
"webpack-hot-middleware": "^2.12.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
|
||||
const bundleOutputDir = './wwwroot/dist';
|
||||
|
||||
var bundleOutputDir = './wwwroot/dist';
|
||||
module.exports = {
|
||||
module.exports = (env) => {
|
||||
const isDevBuild = !(env && env.prod);
|
||||
return [{
|
||||
stats: { modules: false },
|
||||
entry: { 'main': './ClientApp/boot.ts' },
|
||||
resolve: { extensions: [ '', '.js', '.ts' ] },
|
||||
resolve: { extensions: [ '.js', '.ts' ] },
|
||||
output: {
|
||||
path: path.join(__dirname, bundleOutputDir),
|
||||
filename: '[name].js',
|
||||
publicPath: '/dist/'
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader', query: { silent: true } },
|
||||
rules: [
|
||||
{ test: /\.ts$/, include: /ClientApp/, use: 'awesome-typescript-loader?silent=true' },
|
||||
{ test: /\.html$/, loader: 'raw-loader' },
|
||||
{ test: /\.css$/, loader: isDevBuild ? 'style-loader!css-loader' : ExtractTextPlugin.extract(['css-loader']) },
|
||||
{ test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url-loader', query: { limit: 25000 } },
|
||||
{ test: /\.json$/, loader: 'json-loader' }
|
||||
{ test: /\.css$/, loader: isDevBuild ? 'style-loader!css-loader' : ExtractTextPlugin.extract({ loader: 'css-loader' }) },
|
||||
{ test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url-loader?limit=25000' }
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CheckerPlugin(),
|
||||
new webpack.DllReferencePlugin({
|
||||
context: __dirname,
|
||||
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
||||
@@ -34,8 +37,8 @@ module.exports = {
|
||||
})
|
||||
] : [
|
||||
// Plugins that apply in production builds only
|
||||
new webpack.optimize.OccurenceOrderPlugin(),
|
||||
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
|
||||
new webpack.optimize.UglifyJsPlugin(),
|
||||
new ExtractTextPlugin('site.css')
|
||||
])
|
||||
}];
|
||||
};
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
var extractCSS = new ExtractTextPlugin('vendor.css');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
module.exports = (env) => {
|
||||
const isDevBuild = !(env && env.prod);
|
||||
const extractCSS = new ExtractTextPlugin('vendor.css');
|
||||
return [{
|
||||
stats: { modules: false },
|
||||
resolve: {
|
||||
extensions: [ '', '.js' ]
|
||||
extensions: [ '.js' ]
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
|
||||
{ test: /\.css(\?|$)/, loader: extractCSS.extract(['css-loader']) }
|
||||
rules: [
|
||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' },
|
||||
{ test: /\.css(\?|$)/, use: extractCSS.extract({ loader: 'css-loader' }) }
|
||||
]
|
||||
},
|
||||
entry: {
|
||||
@@ -26,12 +28,12 @@ module.exports = {
|
||||
plugins: [
|
||||
extractCSS,
|
||||
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
|
||||
new webpack.optimize.OccurenceOrderPlugin(),
|
||||
new webpack.DllPlugin({
|
||||
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
|
||||
name: '[name]_[hash]'
|
||||
})
|
||||
].concat(isDevBuild ? [] : [
|
||||
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
||||
new webpack.optimize.UglifyJsPlugin()
|
||||
])
|
||||
}];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user