Created
June 23, 2018 16:48
-
-
Save openscript/49fb0b0edc7e7e84142bb164c7dc2b28 to your computer and use it in GitHub Desktop.
This file contains 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 ExtractTextPlugin from 'extract-text-webpack-plugin'; | |
import * as path from 'path'; | |
import {Configuration, DefinePlugin} from 'webpack'; | |
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin'); | |
const config: Configuration = { | |
mode: 'development', | |
watch: true, | |
entry: ['./assets/scripts/index.ts', './assets/styles/index.scss', './assets/sprite/sprite.js'], | |
output: { | |
filename: 'script.js', | |
path: path.join(__dirname, 'static') | |
}, | |
devtool: 'source-map', | |
resolve: { | |
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js'] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?$/, | |
exclude: ['/node_modules/'], | |
use: [{ | |
loader: 'awesome-typescript-loader', | |
options: { | |
configFileName: 'tsconfig.json' | |
} | |
}] | |
}, { | |
test: /\.scss$/, | |
exclude: ['/node_modules/'], | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: [{ | |
loader: 'css-loader' | |
}, { | |
loader: 'sass-loader', | |
options: { | |
sourceMap: true | |
} | |
}] | |
}) | |
}, { | |
test: /\.svg$/, | |
include: [path.join(__dirname, 'assets/sprite')], | |
use: [{ | |
loader: 'svg-sprite-loader', | |
options: { | |
extract: true, | |
spriteFilename: 'sprite.svg' | |
} | |
}], | |
} | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin({ | |
filename: 'style.css' | |
}), | |
new SpriteLoaderPlugin(), | |
new DefinePlugin({ | |
'process.env': { | |
NODE_ENV: JSON.stringify('development'), | |
} | |
}) | |
] | |
}; | |
export = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment