-
-
Save dhamkur/1abb07de7138017e2e547e162c9dbf00 to your computer and use it in GitHub Desktop.
Getting toastr npm to play with webpack
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
import * as Toastr from 'toastr'; | |
import './/../node_modules/toastr/build/toastr.css'; //You need style and css loader installed and set | |
Toastr.options.timeout = 2000; //Change the settings | |
Toastr.info('This works!'); |
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
//In case anyone was having the same issue in getting toastr to run with webpack and es6 | |
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 webpack = require('webpack'); | |
var path = require('path'); | |
var assetsPath = '/assets/javascript'; | |
var destinationPointPath = '/dist'; | |
// Why use ProvidePlugin and externals: http://stackoverflow.com/a/30587246/1771644 | |
module.exports = { | |
entry: `${__dirname}` + '/javascript/src/app.js', | |
output: { | |
path: `${__dirname}`+ '/dist', | |
filename: 'co.js' | |
}, | |
resolve :{ | |
extensions: ["", ".js"] | |
}, | |
externals: { | |
"jquery": "jQuery" | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.css$/, loader: 'style-loader!css-loader' | |
}, | |
{ | |
test: /\.js$/, loader: 'babel', | |
exclude: /(node_modules|bower_components)/, | |
query: { | |
presets: ['es2015'] | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.ProvidePlugin({ | |
$: "jquery" | |
}) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment