Intermediate commit:
- webpack build does not run successfully, typescript errors out, saying "TS2304: Cannot find name 'module'." or 'require' or 'process' in certain .ts files.
This commit is contained in:
parent
d6604351fe
commit
be51aab2ee
43 changed files with 213 additions and 53 deletions
7
config/helpers.js
Normal file
7
config/helpers.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
var path = require('path');
|
||||
var _root = path.resolve(__dirname, '..');
|
||||
function root(args) {
|
||||
args = Array.prototype.slice.call(arguments, 0);
|
||||
return path.join.apply(path, [_root].concat(args));
|
||||
}
|
||||
exports.root = root;
|
76
config/webpack.common.js
Normal file
76
config/webpack.common.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
var webpack = require('webpack');
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
var helpers = require('./helpers');
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
'polyfills': './src/polyfills.ts',
|
||||
'vendor': './src/vendor.ts',
|
||||
'app': './src/main.ts'
|
||||
},
|
||||
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js']
|
||||
},
|
||||
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
loaders: [
|
||||
{
|
||||
loader: 'awesome-typescript-loader',
|
||||
options: {
|
||||
configFileName: helpers.root('src', 'tsconfig.json')
|
||||
}
|
||||
},
|
||||
'angular2-template-loader'
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.html$/,
|
||||
use: 'html-loader'
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
|
||||
use: 'file-loader?name=assets/[name].[hash].[ext]'
|
||||
},
|
||||
// {
|
||||
// test: /\.css$/,
|
||||
// exclude: helpers.root('src', 'app'),
|
||||
// use: ExtractTextPlugin.extract({
|
||||
// fallback: 'style-loader',
|
||||
// use: 'css-loader?sourceMap'
|
||||
// })
|
||||
// },
|
||||
{
|
||||
test: /\.css$/,
|
||||
include: helpers.root('src', 'app'),
|
||||
use: 'raw-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
plugins: [
|
||||
// Workaround for angular/angular#11580
|
||||
new webpack.ContextReplacementPlugin(
|
||||
// The (\\|\/) piece accounts for path separators in *nix and Windows
|
||||
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
|
||||
helpers.root('./src'), // location of your src
|
||||
{} // a map of your routes
|
||||
),
|
||||
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: ['app', 'vendor', 'polyfills']
|
||||
}),
|
||||
|
||||
new HtmlWebpackPlugin({
|
||||
template: 'src/index.html'
|
||||
}),
|
||||
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
comments: false
|
||||
})
|
||||
]
|
||||
};
|
24
config/webpack.dev.js
Normal file
24
config/webpack.dev.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
var webpackMerge = require('webpack-merge');
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
var commonConfig = require('./webpack.common.js');
|
||||
var helpers = require('./helpers');
|
||||
|
||||
module.exports = webpackMerge(commonConfig, {
|
||||
devtool: 'cheap-module-eval-source-map',
|
||||
|
||||
output: {
|
||||
path: helpers.root('dist'),
|
||||
publicPath: 'http://localhost:8080/',
|
||||
filename: '[name].js',
|
||||
chunkFilename: '[id].chunk.js'
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new ExtractTextPlugin('[name].css')
|
||||
],
|
||||
|
||||
devServer: {
|
||||
historyApiFallback: true,
|
||||
stats: 'minimal'
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue