1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- const path = require('path');
- const glob = require('glob');
- var HtmlWebpackPlugin = require('html-webpack-plugin');
- const config = {
- context: path.resolve(__dirname, './'),
- entry: {
- '0_vendor': require('./package.json').bundleDependencies,
- '1_app': './entry.js',
- '2_files': toArray(glob.sync('./app/**/*.js'), 'app.module.js'),
- // 'style': './css/style.scss'
- },
- output: {
- filename: '[name].bundle.js'
- },
- devServer: {
- contentBase: path.join(__dirname, './'),
- compress: true,
- port: 9000,
- stats: 'errors-only',
- watchOptions: { aggregateTimeout: 300, poll: 1000 }
- },
- resolve: {
- alias: {
- 'node_modules': path.join(__dirname, 'node_modules'),
- }
- },
- plugins: [
- new HtmlWebpackPlugin({
- template: 'index.html',
- chunksSortMode: function(a, b) {
- return (a.names[0] > b.names[0])? 1 : -1;
- },
- inject: 'body',
- extraFiles: {
- css: './css/style.css'
- }
- })
- ],
- module: {
- rules: [
- // {test: /\.css$/, use: ['style-loader', 'css-loader']}
- /*{
- test: /\.(s*)css$/,
- use: [
- 'style-loader', // creates style nodes from JS strings
- 'css-loader', // translates CSS into CommonJS
- 'sass-loader' // compiles Sass to CSS
- ]
- }*/
- ]
- }
- };
- module.exports = config;
- function toObject(paths) {
- var result = {};
- paths.forEach(function(path) {
- result[path.split('/').slice(-1)[0]] = path;
- });
- return result;
- }
- function toArray(paths, ignorePath) {
- var result = [];
- paths.forEach(function(path) {
- if (path.indexOf(ignorePath) !== -1) return;
- result.push(path);
- });
- return result;
- }
|