Created
June 7, 2018 13:18
-
-
Save jlebrech/a8c831f4b32d4745614f21bbdd5000a0 to your computer and use it in GitHub Desktop.
webpack 3.1, AngularJS 1.x config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
const webpack = require('webpack'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const CleanWebpackPlugin = require('clean-webpack-plugin'); | |
config = { | |
entry: { | |
app: './app/scripts/main.js', | |
login: './app/scripts/login.js', | |
vendors: './app/scripts/vendors.js' | |
}, | |
output: { | |
filename: '[name].[hash].bundle.js', | |
path: path.resolve(__dirname, 'dist'), | |
publicPath: 'dist/' | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: path.join(__dirname, 'scripts'), | |
loader: 'babel-loader', | |
test: /\.jsx?$/, | |
// Options to configure babel with | |
query: { | |
// plugins: ['transform-runtime'], | |
presets: ['es2015'], | |
} | |
}, | |
{ | |
test: /\.css$/, | |
loader: "style-loader!css-loader!resolve-url-loader" | |
}, | |
{ | |
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/, | |
loader: 'file-loader' | |
} | |
] | |
}, | |
// externals: [ | |
// 'angular', 'jquery','lodash','moment','pnotify' | |
// ], | |
// resolve: { | |
// alias: { | |
// 'angular': '../../node_modules/angular/angular.min.js', | |
// 'jQuery': 'jquery', | |
// '_': 'lodash' | |
// } | |
// }, | |
externals: { | |
angular: 'angular' | |
}, | |
resolve: { | |
alias: { | |
'angular': '../../node_modules/angular/angular.min.js', | |
'jQuery': 'jquery' | |
} | |
}, | |
plugins: [ | |
new CleanWebpackPlugin(['app/dist']), | |
new webpack.SourceMapDevToolPlugin({ | |
append: "\n//# sourceMappingURL=http://localhost:8080/dist/[url]", | |
filename: '[name].bundle.js.map' | |
}), | |
new HtmlWebpackPlugin({ | |
filename: '../index.html', | |
template: 'app/templates/index.html', | |
chunksSortMode: 'manual', | |
chunks: ['vendors', 'app'] | |
}), | |
new HtmlWebpackPlugin({ | |
filename: '../login.html', | |
template: 'app/templates/login.html', | |
chunksSortMode: 'manual', | |
chunks: ['vendors', 'login'] | |
}) | |
] | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment