Created
February 14, 2017 11:33
-
-
Save raphaelsoul/30f5ee23627cd0899ab894902bc57d6f to your computer and use it in GitHub Desktop.
webpack 2.0 configuration example
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
| const path = require('path') | |
| const ExtractTextPlugin = require("extract-text-webpack-plugin") | |
| const prod = process.argv.indexOf('-p') !== -1 | |
| const theme = 'geil' | |
| const ProjectRoot = path.dirname(path.dirname(path.dirname(__dirname))) | |
| const TargetWebRoot = path.join(ProjectRoot, 'blog', 'web', 'themes', theme) | |
| const ResourceRoot = path.join(__dirname, 'resources') | |
| const PUBLIC_URL_PREFIX = '/themes/' + theme | |
| const extractSass = new ExtractTextPlugin({ | |
| filename: "[name]/[name].css", | |
| }); | |
| const config = { | |
| entry : { | |
| frontend: path.join(ResourceRoot, 'frontend', 'app.js'), | |
| backend : path.join(ResourceRoot, 'backend', 'app.js') | |
| }, | |
| output: { | |
| filename: '[name]/[name].bundle.js', | |
| path : TargetWebRoot | |
| }, | |
| /*resolve: { | |
| modules: ['node_modules'] | |
| },*/ | |
| module: { | |
| rules: [ | |
| { | |
| test : /\.(scss|sass)$/, | |
| loader: extractSass.extract({ | |
| loader: [{ | |
| loader : "css-loader", | |
| options: { | |
| //minimize : true, | |
| //sourceMap: true | |
| } | |
| }, { | |
| loader : "sass-loader", | |
| options: { | |
| includePaths: [path.join(ResourceRoot, 'node_modules')], | |
| //url : false | |
| } | |
| }], | |
| // use style-loader in development | |
| //fallbackLoader: "style-loader" | |
| }) | |
| }, | |
| { | |
| test : /\.(png|jpg|jpeg|gif|svg)$/, | |
| loader: "file-loader?name=[name].[ext]&publicPath=../assets/images/&outputPath=assets/images/", | |
| }, | |
| { | |
| test : /\.(eot|ttf|woff|woff2)$/, | |
| loader: "file-loader?name=[name].[ext]&publicPath=../assets/fonts/&outputPath=assets/fonts/", | |
| }, | |
| { | |
| test : /\.(png|jpg)$/, | |
| loader: "url-loader?limit=40000", | |
| }, | |
| { | |
| test: require.resolve("pace-progress"), | |
| loader: "imports-loader?define=>false" | |
| }, | |
| { | |
| test: require.resolve("editor.md"), | |
| loader: "imports-loader?define=>false" | |
| } | |
| ] | |
| }, | |
| plugins: [ | |
| extractSass | |
| ] | |
| } | |
| module.exports = config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment